From 99c7ad8923c2f604d132895b172e59a8bd725882 Mon Sep 17 00:00:00 2001 From: cmaumet Date: Fri, 7 Jul 2017 09:02:01 +0100 Subject: [PATCH] containers to struct --- snpm_cp.m | 124 +++++++++++++++++++++--------------------------------- snpm_ui.m | 16 +++---- 2 files changed, 57 insertions(+), 83 deletions(-) diff --git a/snpm_cp.m b/snpm_cp.m index becd723..4e80a76 100644 --- a/snpm_cp.m +++ b/snpm_cp.m @@ -217,22 +217,22 @@ function snpm_cp(CWD) if strcmp(sDesFile, 'snpm_pi_OneSampT') || ... strcmp(sDesFile, 'snpm_pi_ANOVAwithinS') % Sign flipping - nidm_json('nidm_ErrorModel/nidm_hasErrorDistribution') = {'obo_nonparametricdistribution', 'obo_symmetricdistribution'}; - nidm_json('nidm_ErrorModel/nidm_errorVarianceHomogeneous') = false; - nidm_json('nidm_ErrorModel/nidm_varianceMapWiseDependence') = 'nidm_IndependentParameter'; - nidm_json('nidm_ErrorModel/nidm_hasErrorDependence') = 'nidm_IndependentError'; + nidm.ErrorModel_hasErrorDistribution = {'obo_nonparametricdistribution', 'obo_symmetricdistribution'}; + nidm.ErrorModel_errorVarianceHomogeneous = false; + nidm.ErrorModel_varianceMapWiseDependence = 'nidm_IndependentParameter'; + nidm.ErrorModel_hasErrorDependence = 'nidm_IndependentError'; else % Permutation - nidm_json('nidm_ErrorModel/nidm_hasErrorDistribution') = 'obo_nonparametricdistribution'; - nidm_json('nidm_ErrorModel/nidm_errorVarianceHomogeneous') = true; - nidm_json('nidm_ErrorModel/nidm_varianceMapWiseDependence') = 'nidm_IndependentParameter'; + nidm.ErrorModel_hasErrorDistribution = 'obo_nonparametricdistribution'; + nidm.ErrorModel_errorVarianceHomogeneous = true; + nidm.ErrorModel_varianceMapWiseDependence = 'nidm_IndependentParameter'; % TODO: the 'obo_exchangeable' term is not yet in STATO - nidm_json('nidm_ErrorModel/nidm_hasErrorDependence') = 'obo_exchangeable'; - nidm_json('nidm_ErrorModel/nidm_dependenceMapWiseDependence') = 'nidm_IndependentParameter'; + nidm.ErrorModel_hasErrorDependence = 'obo_exchangeable'; + nidm.ErrorModel_dependenceMapWiseDependence = 'nidm_IndependentParameter'; end % TODO: check this is correct -nidm_json('nidm_ModelParameterEstimation/nidm_withEstimationMethod') = 'obo_ordinaryleastsquaresestimation'; +nidm.ModelParameterEstimation_withEstimationMethod = 'obo_ordinaryleastsquaresestimation'; if isempty([H C]) error('SnPM:NoModel', 'No model specified; [H C] empty'); @@ -244,44 +244,38 @@ function snpm_cp(CWD) error('SnPM:InvalidContrast','Contrast problem; wrong number of columns'); end -if size(CONT,1) > 1 - contrastMap = containers.Map(); - contrastMap('obo_contrastweightmatrix/prov:value') = CONT; +if size(CONT,1) > 1 % F-contrast + nidm.Contrasts(1).contrastweightmatrix_value = CONT; warning('SnPM:FContrast', ... 'F contrast! F statistic images are being created.'); STAT = 'F'; - contrastMap('nidm_StatisticMap/nidm_statisticType') = 'obo_Fstatistic'; + nidm.Contrasts(1).StatisticMap_statisticType = 'obo_Fstatistic'; + if (CONT(1,:) == -CONT(2,:)) CONT = CONT(1,:); end con_name = 'Positive'; - - nidm_json('Contrasts') = containers.Map({con_name}, {contrastMap}); + nidm.Contrasts(1).StatisticMap_contrastName = con_name; con_neg_name = ''; else - contrast_pos = containers.Map(); - contrast_neg = containers.Map(); % There is no deep copy of - % containers.Map so we need a separate object from the start con_name = 'Positive'; + nidm.Contrasts(1).StatisticMap_contrastName = con_name; + con_neg_name = 'Negative'; + nidm.Contrasts(2).StatisticMap_contrastName = con_neg_name; + STAT = 'T'; if bVarSm - contrast_pos('nidm_StatisticMap/nidm_statisticType') = 'nidm_smoothedtstatistic'; - contrast_neg('nidm_StatisticMap/nidm_statisticType') = 'nidm_smoothedtstatistic'; + nidm.Contrasts(1).StatisticMap_statisticType = 'nidm_smoothedtstatistic'; + nidm.Contrasts(2).StatisticMap_statisticType = 'nidm_smoothedtstatistic'; else - contrast_pos('nidm_StatisticMap/nidm_statisticType') = 'obo_tstatistic'; - contrast_neg('nidm_StatisticMap/nidm_statisticType') = 'obo_tstatistic'; + nidm.Contrasts(1).StatisticMap_statisticType = 'obo_tstatistic'; + nidm.Contrasts(2).StatisticMap_statisticType = 'obo_tstatistic'; end - contrast_pos('nidm_ContrastMap/nidm_contrastName') = ['Positive T-Contrast: [' mat2str(CONT) ']']; - contrast_pos('obo_contrastweightmatrix/prov:value') = CONT; - contrast_neg('nidm_ContrastMap/nidm_contrastName') = ['Negative T-Contrast: [' mat2str(-CONT) ']']; - contrast_neg('obo_contrastweightmatrix/prov:value') = -CONT; - -% nidm_json('Contrasts').(con_name) = contrast_pos; -% nidm_json('Contrasts').(con_neg_name) = contrast_neg; - - nidm_json('Contrasts') = containers.Map({con_name, con_neg_name}, ... - {contrast_pos, contrast_neg}); + nidm.Contrasts(1).ContrastMap_contrastName = ['Positive T-Contrast: [' mat2str(CONT) ']']; + nidm.Contrasts(1).contrastweightmatrix_value = CONT; + nidm.Contrasts(2).ContrastMap_contrastName = ['Negative T-Contrast: [' mat2str(-CONT) ']']; + nidm.Contrasts(2).contrastweightmatrix_value = -CONT; end if rank(CONT)