-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] hacky fix for FDRCorrector default (#663)
* hacky fix for FDRCorrector default * add constants file and reference from there * add back in algorithm arguments as defaults as well
- Loading branch information
Showing
3 changed files
with
81 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...s/CreateMetaAnalysisSpecificationDialog/CreateMetaAnalysisSpecificationDialogConstants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { | ||
IMetaAnalysisParamsSpecification, | ||
IDynamicValueType, | ||
} from 'components/MetaAnalysisConfigComponents'; | ||
import { EAnalysisType } from 'hooks/metaAnalyses/useCreateAlgorithmSpecification'; | ||
import { IAutocompleteObject } from 'components/NeurosynthAutocomplete/NeurosynthAutocomplete'; | ||
import metaAnalysisSpec from 'assets/config/meta_analysis_params.json'; | ||
|
||
const getDefaultValuesForTypeAndParameter = ( | ||
type: EAnalysisType | 'CORRECTOR', | ||
parameterLabel: string | undefined | ||
): IDynamicValueType => { | ||
if (type && parameterLabel) { | ||
const parameters = metaAnalysisSpecification[type][parameterLabel].parameters; | ||
const defaultVals: IDynamicValueType = {}; | ||
for (const [key, value] of Object.entries(parameters)) { | ||
if (parameters[key].type === null) { | ||
// in the case of kwargs or any other input with no default value | ||
defaultVals[key] = {}; | ||
} else { | ||
defaultVals[key] = value.default; | ||
} | ||
} | ||
|
||
return defaultVals; | ||
} | ||
|
||
return {}; | ||
}; | ||
|
||
const metaAnalysisSpecification: IMetaAnalysisParamsSpecification = metaAnalysisSpec; | ||
|
||
const metaAnalyticAlgorithms: IAutocompleteObject[] = Object.keys( | ||
metaAnalysisSpecification[EAnalysisType.CBMA] | ||
).map((algoName) => ({ | ||
label: algoName, | ||
description: metaAnalysisSpecification[EAnalysisType.CBMA][algoName]?.summary || '', | ||
})); | ||
|
||
const correctorOptions: IAutocompleteObject[] = Object.keys( | ||
metaAnalysisSpecification.CORRECTOR | ||
).map((corrector) => ({ | ||
label: corrector, | ||
description: metaAnalysisSpecification.CORRECTOR[corrector]?.summary, | ||
})); | ||
|
||
const correctorOpt = | ||
correctorOptions.find((corrector) => corrector.label === 'FDRCorrector') || null; | ||
const algorithmOpt = metaAnalyticAlgorithms.find((algo) => algo.label === 'MKDADensity') || null; | ||
|
||
export { | ||
getDefaultValuesForTypeAndParameter, | ||
metaAnalysisSpecification, | ||
metaAnalyticAlgorithms, | ||
correctorOptions, | ||
correctorOpt, | ||
algorithmOpt, | ||
}; |