Skip to content

Commit 57ec646

Browse files
eurunuelaclaude
andcommitted
feat: Filter Carpets and QC Histograms by selected run
Extend the per-run grouping to carpetFigures and diagnosticFigures so all tabs consistently show only the selected run's content. Previously these two arrays were kept flat (all runs mixed together), which made Carpets and QC Histograms work "accidentally" but inconsistently with the rest of the tabs. Now they are run-indexed arrays like all other per-run data, and index.js slices them with carpetFigures[r] / diagnosticFigures[r] before passing to the tabs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f48acca commit 57ec646

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/PopUps/IntroPopUp.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ function IntroPopup({ onDataLoad, onLoadingStart, closePopup, isLoading, isDark
183183

184184
// Per-run accumulators (indexed arrays)
185185
const compFigures = Array.from({ length: N }, () => []);
186-
const carpetFigures = []; // flat — already multi-run tolerant
187-
const diagnosticFigures = []; // flat — already multi-run tolerant
186+
const carpetFigures = Array.from({ length: N }, () => []);
187+
const diagnosticFigures = Array.from({ length: N }, () => []);
188188
const info = new Array(N).fill("");
189189
const components = new Array(N).fill(null).map(() => []);
190190
const originalData = new Array(N).fill(null).map(() => []);
@@ -223,11 +223,11 @@ function IntroPopup({ onDataLoad, onLoadingStart, closePopup, isLoading, isDark
223223
const blob = await response.blob();
224224
const dataUrl = await blobToDataURL(blob);
225225
if (filename.includes("carpet_")) {
226-
carpetFigures.push({ name: filename, img: dataUrl });
226+
for (const i of targets) carpetFigures[i].push({ name: filename, img: dataUrl });
227227
} else if (filename.includes("confound_correlations")) {
228228
for (const i of targets) externalRegressorsFigure[i] = dataUrl;
229229
} else {
230-
diagnosticFigures.push({ name: filename, img: dataUrl });
230+
for (const i of targets) diagnosticFigures[i].push({ name: filename, img: dataUrl });
231231
}
232232
setLoadingProgress((prev) => ({ ...prev, current: prev.current + 1 }));
233233
}
@@ -414,13 +414,13 @@ function IntroPopup({ onDataLoad, onLoadingStart, closePopup, isLoading, isDark
414414
});
415415
await Promise.all(filePromises);
416416

417-
// Sort component figures by name per run
417+
// Sort figures by name per run, apply manual classifications
418418
for (let i = 0; i < N; i++) {
419419
compFigures[i].sort((a, b) => a.name.localeCompare(b.name));
420+
carpetFigures[i].sort((a, b) => a.name.localeCompare(b.name));
421+
diagnosticFigures[i].sort((a, b) => a.name.localeCompare(b.name));
420422
applyManualClassifications(components[i], manualClassificationData[i]);
421423
}
422-
carpetFigures.sort((a, b) => a.name.localeCompare(b.name));
423-
diagnosticFigures.sort((a, b) => a.name.localeCompare(b.name));
424424

425425
trackDatasetLoaded();
426426

@@ -553,8 +553,8 @@ function IntroPopup({ onDataLoad, onLoadingStart, closePopup, isLoading, isDark
553553

554554
// Per-run accumulators (indexed arrays)
555555
const compFigures = Array.from({ length: N }, () => []);
556-
const carpetFigures = []; // flat — already multi-run tolerant
557-
const diagnosticFigures = []; // flat — already multi-run tolerant
556+
const carpetFigures = Array.from({ length: N }, () => []);
557+
const diagnosticFigures = Array.from({ length: N }, () => []);
558558
const info = new Array(N).fill("");
559559
const components = new Array(N).fill(null).map(() => []);
560560
const originalData = new Array(N).fill(null).map(() => []);
@@ -588,11 +588,11 @@ function IntroPopup({ onDataLoad, onLoadingStart, closePopup, isLoading, isDark
588588
if (filename.endsWith(".svg")) {
589589
const dataUrl = await readFileAsDataURL(file);
590590
if (filename.includes("carpet_")) {
591-
carpetFigures.push({ name: filename, img: dataUrl });
591+
for (const i of targets) carpetFigures[i].push({ name: filename, img: dataUrl });
592592
} else if (filename.includes("confound_correlations")) {
593593
for (const i of targets) externalRegressorsFigure[i] = dataUrl;
594594
} else {
595-
diagnosticFigures.push({ name: filename, img: dataUrl });
595+
for (const i of targets) diagnosticFigures[i].push({ name: filename, img: dataUrl });
596596
}
597597
setLoadingProgress((prev) => ({ ...prev, current: prev.current + 1 }));
598598
}
@@ -763,13 +763,13 @@ function IntroPopup({ onDataLoad, onLoadingStart, closePopup, isLoading, isDark
763763
// Wait for all files to be processed
764764
await Promise.all(filePromises);
765765

766-
// Sort component figures by name per run, apply manual classifications
766+
// Sort figures by name per run, apply manual classifications
767767
for (let i = 0; i < N; i++) {
768768
compFigures[i].sort((a, b) => a.name.localeCompare(b.name));
769+
carpetFigures[i].sort((a, b) => a.name.localeCompare(b.name));
770+
diagnosticFigures[i].sort((a, b) => a.name.localeCompare(b.name));
769771
applyManualClassifications(components[i], manualClassificationData[i]);
770772
}
771-
carpetFigures.sort((a, b) => a.name.localeCompare(b.name));
772-
diagnosticFigures.sort((a, b) => a.name.localeCompare(b.name));
773773

774774
trackDatasetLoaded();
775775

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,11 +514,11 @@ function App() {
514514
/>
515515
</TabPanel>
516516
<TabPanel index={2}>
517-
<Carpets images={carpetFigures} isDark={isDark} />
517+
<Carpets images={carpetFigures?.[r] || []} isDark={isDark} />
518518
</TabPanel>
519519
<TabPanel index={3}>
520520
<Diagnostics
521-
images={diagnosticFigures}
521+
images={diagnosticFigures?.[r] || []}
522522
qcNiftiBuffers={qcNiftiBuffers?.[r] || {}}
523523
maskBuffer={maskBuffer?.[r]}
524524
isDark={isDark}

0 commit comments

Comments
 (0)