Skip to content

Commit 49af43d

Browse files
committed
fix: order
1 parent abca406 commit 49af43d

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

compose/neurosynth-frontend/src/components/Visualizer/ThresholdSlider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ const ThresholdSlider: React.FC<{
183183
}}
184184
></Slider>
185185
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
186+
{/* no mechanism exists yet to allow for soft threshold AND adjustable cal_min. Uncomment this if we want to add an adjustable min in the future, the useEffect infrastructure to do so already exists above */}
186187
{/* <TextField
187188
sx={{
188189
width: '60px',

compose/neurosynth-frontend/src/hooks/metaAnalyses/useGetNeurovaultImages.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ export interface INeurovault {
6060
function useGetNeurovaultImages(neurovaultImages: string[]) {
6161
return useQuery({
6262
queryKey: ['neurovault-images', ...neurovaultImages],
63+
6364
queryFn: async () => {
6465
const res = await Promise.all<AxiosResponse<INeurovault>>(neurovaultImages.map((url) => axios.get(url)));
66+
6567
return res.map((x) => ({
6668
...x.data,
6769
file: (x.data.file || '').replace(/http/, 'https'), // without this, link will redirect but result in an error

compose/neurosynth-frontend/src/pages/MetaAnalysis/components/DisplayMetaAnalysisResults.spec.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ const caseMKDAChi2: Partial<INeurovault>[] = [
4848
{ id: 5, name: 'z_desc-associationMass' },
4949
];
5050

51+
const caseNotZAlphabetical: Partial<INeurovault>[] = [
52+
{ id: 2, name: 'p_desc-DEF' },
53+
{ id: 1, name: 'p_desc-ABC' },
54+
];
55+
5156
const caseMoreSegments: Partial<INeurovault>[] = [
5257
{ id: 2, name: 'z_desc-association_level-voxel_corr-FDR_method-indep.nii.gz' },
5358
{ id: 1, name: 'z_desc-association.nii.gz' },
@@ -148,6 +153,20 @@ describe('DisplayMetaAnalysisResults', () => {
148153
expect(buttons[4].textContent).toBe('z_desc-ZZZ');
149154
});
150155

156+
it('should show the correctly sorted list for non z maps', () => {
157+
(useGetNeurovaultImages as Mock).mockReturnValue({
158+
data: caseNotZAlphabetical,
159+
isLoading: false,
160+
isError: false,
161+
});
162+
163+
render(<DisplayMetaAnalysisResults metaAnalysis={mockMetaAnalysisReturn()} />);
164+
const buttons = screen.getAllByRole('button');
165+
expect(buttons.length).toEqual(caseNotZAlphabetical.length);
166+
expect(buttons[0].textContent).toBe('p_desc-ABC');
167+
expect(buttons[1].textContent).toBe('p_desc-DEF');
168+
});
169+
151170
it('should show the correctly sorted list if one file name is larger than the other', () => {
152171
(useGetNeurovaultImages as Mock).mockReturnValue({
153172
data: caseMoreSegments,

compose/neurosynth-frontend/src/pages/MetaAnalysis/components/DisplayMetaAnalysisResults.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const DisplayMetaAnalysisResults: React.FC<{
3333
if (!neurovaultFiles || !metaAnalysis || !(metaAnalysis?.specification as Specification).estimator?.type)
3434
return [];
3535

36-
const orderMap = new Map(NimareOutputs.map((output, index) => [output.key, index]));
36+
const orderMap = new Map(NimareOutputs.reverse().map((output, index) => [output.key, index]));
3737
// We want the order of the files to be very specific:
3838
// if algorithm is MKDAChi2, then set 1st image to be z_desc-associationMass
3939
// set 2nd image to be z_desc-uniformityMass
@@ -51,8 +51,8 @@ const DisplayMetaAnalysisResults: React.FC<{
5151
const segmentB = filenameB[i];
5252

5353
if (!segmentA && !segmentB) return 0;
54-
else if (!segmentA) return -1;
55-
else if (!segmentB) return 1;
54+
else if (!segmentA) return 1;
55+
else if (!segmentB) return -1;
5656

5757
const orderA = orderMap.get(segmentA.key) ?? Infinity;
5858
const orderB = orderMap.get(segmentB.key) ?? Infinity;
@@ -61,7 +61,7 @@ const DisplayMetaAnalysisResults: React.FC<{
6161
if (segmentA.value === segmentB.value) continue;
6262
return segmentA.value.localeCompare(segmentB.value);
6363
} else {
64-
return orderB - orderA;
64+
return orderA - orderB;
6565
}
6666
}
6767
return 0;
@@ -85,7 +85,7 @@ const DisplayMetaAnalysisResults: React.FC<{
8585
}
8686
}
8787

88-
return sorted.reverse();
88+
return sorted;
8989
}, [neurovaultFiles, metaAnalysis]);
9090

9191
useEffect(() => {

0 commit comments

Comments
 (0)