Open dkp opened 3 years ago
Hello, thanks for using the toolbox. Error #3 does appear to be related to Glmnet- Noisecloud is expecting different number of output arguments from glmnetMex. Could you try this version- https://web.stanford.edu/~hastie/glmnet_matlab/download.html ? Seems it is "Tested with Matlab 2020b on Mac OS 11". I do not have access to MacOS but I will try to have it tested.
I'll note to add #2 as a feature (being able to run labeling without running Noisecloud) and try to push an update to the toolbox soon. The pretrained model is not exactly the model, it is Noisecloud features extracted from HCP and FBIRN datasets, which are used to train the model on the fly. I think if the above glmnet version works on Mac , the training should also work fine.
Thanks for the quick response.
I have not run noisecloud, because its purpose is mysterious to me (I have to identify the noise vs signal ICs first, then run it to identify noise vs signal?). If it could train on some established dataset (like your fbirn one) and then apply what it had learned to my data, that would be useful...but so far, I have not got enough understanding to make that work. Here's my test dataset, in case it helps reveal bad assumptions on my part.
I downloaded the suggested version of glmnet and tried autolabeller again. The failure is quick:
>> autolabel_ic
Running the autolabeller on FBIRN training dataset
predicting networks
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the
VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
Coregistering /Volumes/Main/Users/dpat/Downloads/nifti_subjects/gift_analysis_nodir/vm_mean_component_ica_s_all_.nii,1 to functional image /usr/local/MATLAB_TOOLS/autolabeller/bin/autolabeller/data/nc_features/fbirn_subxxx_component.nii,1
Coregistering /Volumes/Main/Users/dpat/Downloads/nifti_subjects/gift_analysis_nodir/vm_mean_component_ica_s_all_.nii,1 to /usr/local/MATLAB_TOOLS/autolabeller/bin/autolabeller/data/nc_features/fbirn_subxxx_component.nii,1 ...
SPM12: spm_coreg (v6435) 10:29:45 - 15/06/2021
========================================================================
Completed : 10:29:50 - 15/06/2021
Reslicing ...
SPM12: spm_reslice (v7141) 10:29:51 - 15/06/2021
========================================================================
Completed : 10:29:52 - 15/06/2021
Done
Computing spatial and temporal features of training data ...
Building classifier using logistic regression ...
Running GLMNET (logistic regression with elastic net
K: 10
Grid search for alpha between 0,1 and 1
Type: binomial
Performing cross validated grid search for alpha...
Running fold 1 of 10
Matrix dimensions must agree.
Error in glmnetPredict (line 273)
nbeta=nbeta(:,lamlist.left).*repmat(lamlist.frac',size(nbeta,1),1) +nbeta(:,lamlist.right).*(1-repmat(lamlist.frac',size(nbeta,1),1));
Error in noisecloud_glmnetCV (line 84)
Yest = glmnetPredict(fit, 'class', Xtest); % predict the response, result Yest is a M x nLambas matrix
Error in noisecloud_runGlmnetCV (line 26)
REALRESULT = noisecloud_glmnetCV(X,y,K,Lambda,alphav,type);
Error in noisecloud_classify (line 54)
RESULT = noisecloud_runGlmnetCV(features_norm,labels.decision,K,iterations,alphav,Lambda,type,feature_labels);
Error in noisecloud_run (line 127)
result_nc_classifier = noisecloud_classify(features_norm, feature_labels, labels, 'iterations', num_iterations, 'cross_validation', num_cross_validation, 'threshold', threshold);
Error in label_network_nc (line 86)
[network_pred, fit_mdl, result_nc_classifier] = noisecloud_run(training_opts, testing_opts, 'convert_to_z', 'yes', 'outDir', outpath, 'coregister', 1, ...
Error in label_auto_main (line 112)
network_labels = label_network_nc( fullfile( params.outpath, 'nc' ), sesInfo, sm_path, params.noise_training_set, params.threshold );
Error in autolabel_ic (line 28)
label_auto_main( params );
Hi, I just pushed an update to the code, so now you can skip the noisecloud part (i.e. set params.skip_noise = 1
). Please let me know if you have a chance to test it. I am still trying to find a solution for Mac Glmnet. Thanks!
Hi,
Thanks so much for working on this! I tried it right away:
I changed to this option in the script: set params.skip_noise = 1
>> autolabel_ic
Running the autolabeller on FBIRN training dataset
resampling to AAL atlas
Error using iimg_read_img>vol_file_check (line 319)
Image "/Volumes/Main/Users/dpat/Downloads/nifti_subjects/gift_analysis_nodir/vmMask.img" does not exist or cannot be
found on path (unzipped or .gz versions)!
Error in iimg_read_img>iimg_read_from_file (line 201)
imname = vol_file_check(imname, dofirstvolonly);
Error in iimg_read_img (line 118)
[volInfo, dat] = iimg_read_from_file(space_defining_image, extended_output_flag, reading_data, first_vol);
Error in fmri_mask_image (line 132)
[obj.volInfo, obj.dat] = iimg_read_img(image_name, 2, 1, 1); % reads first vol only
Error in fmri_data (line 492)
maskobj = fmri_mask_image(maskinput);
Error in label_anatomical (line 13)
sm_dat = fmri_data( sm_file, mask_file, 'noverbose' );
Error in label_auto_main (line 128)
[anat_labels, corrs_] = label_anatomical( sm_path, mask_path, params.threshold, network_labels,
params.anatomical_atlas, params.n_corr);
Error in autolabel_ic (line 28)
label_auto_main( params );
However, the relevant NIfTI file exists: /Volumes/Main/Users/dpat/Downloads/nifti_subjects/gift_analysis_nodir/vmMask.nii
NOTE: I AM working with gzipped NIFTI files (in my original dataset), because this is exactly what fMRIPrep is going to create, and GIFT mostly handles this well. You can see this in my test dataset under derivatives.
Hello, the error seems to originate from the Canlab toolbox. I have updated the code to remove dependency on this toolbox. I appreciate your patience while I try to weed out these bugs :)
I saw that this referred to the Canlab toolbox, which has obviously been around a long time and grown to be very large. I imagine refactoring is no fun, but I look forward to the new cleaner codebase....I appreciate your time. Let me know if and when I should pull and test again.
Thanks! The fix for https://github.com/esalman/autolabeller/issues/1#issuecomment-863350121 is there. Thanks for providing the test dataset, I am still looking into the earlier errors.
Thank you, I take it that by #1, you mean the MEX file problem. I just retried your current codebase and I still get the error related to the vmMask.img not being found. This happens whether Canlab is in the path or not. I am excited about the autolabeller, but i can wait ; )
Hello, so I was referring to the commend related to the Mask error, sorry it was not clear! I just pushed another fix, with this one the mask related error should be gone.
I also ran the test dataset you provided earlier, I can run it successfully on my Windows machine. Following are the parameters:
clear
tStart = tic;
addpath( genpath( 'C:\Users\salman\Dropbox (GSU Dropbox)\tools\GroupICATv4.0b\icatb\' ) ) % GIFT toolbox
addpath( 'C:\Users\salman\Dropbox (GSU Dropbox)\tools\spm12\' ) % SPM12 toolbox
addpath( 'C:\Users\salman\Downloads\BCT\2019_03_03_BCT\' ) % Brain connectivity toolbox
addpath( 'C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\autolabeller\bin\autolabeller\' ) % add the autolabeller src folder only
% GICA example with fbirn dataset
clear params;
params.param_file = 'C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\labeller_test\gift_analysis_nodir\vm_ica_parameter_info.mat';
params.outpath = 'C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\results\classify_ic';
params.fit_method = 'mnr';
params.n_corr = 3;
% test setting this to 1 (which fails immediately)
params.skip_noise = 0;
params.skip_anatomical = 0;
params.skip_functional = 0;
params.noise_training_set = 'pre_fbirn_sub';
params.anatomical_atlas = 'aal';
params.threshold = 3;
params.functional_atlas = 'yeo_buckner';
% params.functional_atlas = 'gordon2016';
% params.functional_atlas = 'caren';
disp( 'Running the autolabeller on FBIRN training dataset' )
label_auto_main( params );
tEnd = toc(tStart)
And following is the output:
>> autolabel_ic
Running the autolabeller on FBIRN training dataset
mask_path =
'C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\labeller_test\gift_analysis_nodir\vmMask.nii'
predicting networks
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before
creating variable names for the table. The original column headers are saved in the
VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
Coregistering C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\labeller_test\gift_analysis_nodir\vm_mean_component_ica_s_all_.nii,1 to functional image C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\autolabeller\bin\autolabeller\data\nc_features\fbirn_subxxx_component.nii,1
Coregistering C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\labeller_test\gift_analysis_nodir\vm_mean_component_ica_s_all_.nii,1 to C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\autolabeller\bin\autolabeller\data\nc_features\fbirn_subxxx_component.nii,1 ...
SPM12: spm_coreg (v6435) 18:21:56 - 24/06/2021
========================================================================
Completed : 18:22:04 - 24/06/2021
Reslicing ...
SPM12: spm_reslice (v5929) 18:22:04 - 24/06/2021
========================================================================
Completed : 18:22:05 - 24/06/2021
Done
Computing spatial and temporal features of training data ...
Building classifier using logistic regression ...
Running GLMNET (logistic regression with elastic net
K: 10
Grid search for alpha between 0,1 and 1
Type: binomial
Performing cross validated grid search for alpha...
Running fold 1 of 10
Running fold 2 of 10
Running fold 3 of 10
Running fold 4 of 10
Running fold 5 of 10
Running fold 6 of 10
Running fold 7 of 10
Running fold 8 of 10
Running fold 9 of 10
Running fold 10 of 10
Training cross validated model with optimal parameters...
Alpha: 0.1
Best CVA: 0.81136
Lambda: 0.0625
Plotting ROC curve
Computing spatial and temporal features of testing data ...
Coregistering aal2mni152.nii to functional image ...
Coregistering C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\autolabeller\bin\autolabeller\bin\noisecloud\mr\raw\aal2mni152.nii to C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\results\classify_ic\nc\rvm_mean_component_ica_s_all_.nii,1 ...
SPM12: spm_coreg (v6435) 18:23:22 - 24/06/2021
========================================================================
Completed : 18:23:34 - 24/06/2021
Reslicing ...
SPM12: spm_reslice (v5929) 18:23:34 - 24/06/2021
========================================================================
Completed : 18:23:34 - 24/06/2021
Done
Coregistering grey.nii to functional image ...
Coregistering C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\autolabeller\bin\autolabeller\bin\noisecloud\mr\raw\grey.nii to C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\results\classify_ic\nc\rvm_mean_component_ica_s_all_.nii,1 ...
SPM12: spm_coreg (v6435) 18:23:34 - 24/06/2021
========================================================================
Completed : 18:23:46 - 24/06/2021
Reslicing ...
SPM12: spm_reslice (v5929) 18:23:46 - 24/06/2021
========================================================================
Completed : 18:23:46 - 24/06/2021
Done
Coregistering white.nii to functional image ...
Coregistering C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\autolabeller\bin\autolabeller\bin\noisecloud\mr\raw\white.nii to C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\results\classify_ic\nc\rvm_mean_component_ica_s_all_.nii,1 ...
SPM12: spm_coreg (v6435) 18:23:46 - 24/06/2021
========================================================================
Completed : 18:24:02 - 24/06/2021
Reslicing ...
SPM12: spm_reslice (v5929) 18:24:02 - 24/06/2021
========================================================================
Completed : 18:24:02 - 24/06/2021
Done
Coregistering csf.nii to functional image ...
Coregistering C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\autolabeller\bin\autolabeller\bin\noisecloud\mr\raw\csf.nii to C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\results\classify_ic\nc\rvm_mean_component_ica_s_all_.nii,1 ...
SPM12: spm_coreg (v6435) 18:24:02 - 24/06/2021
========================================================================
Completed : 18:24:17 - 24/06/2021
Reslicing ...
SPM12: spm_reslice (v5929) 18:24:18 - 24/06/2021
========================================================================
Completed : 18:24:18 - 24/06/2021
Done
Coregistering MNI152_T1_2mm_edges.nii to functional image ...
Coregistering C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\autolabeller\bin\autolabeller\bin\noisecloud\mr\raw\MNI152_T1_2mm_edges.nii to C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\results\classify_ic\nc\rvm_mean_component_ica_s_all_.nii,1 ...
SPM12: spm_coreg (v6435) 18:24:18 - 24/06/2021
========================================================================
Completed : 18:24:26 - 24/06/2021
Reslicing ...
SPM12: spm_reslice (v5929) 18:24:26 - 24/06/2021
========================================================================
Completed : 18:24:26 - 24/06/2021
Done
Coregistering MNI152_T1_2mm_strucseg.nii to functional image ...
Coregistering C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\autolabeller\bin\autolabeller\bin\noisecloud\mr\raw\MNI152_T1_2mm_strucseg.nii to C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\results\classify_ic\nc\rvm_mean_component_ica_s_all_.nii,1 ...
SPM12: spm_coreg (v6435) 18:24:26 - 24/06/2021
========================================================================
Completed : 18:24:35 - 24/06/2021
Reslicing ...
SPM12: spm_reslice (v5929) 18:24:35 - 24/06/2021
========================================================================
Completed : 18:24:35 - 24/06/2021
Done
Coregistering MNI152_T1_2mm_eye_mask.nii to functional image ...
Coregistering C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\autolabeller\bin\autolabeller\bin\noisecloud\mr\raw\MNI152_T1_2mm_eye_mask.nii to C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\results\classify_ic\nc\rvm_mean_component_ica_s_all_.nii,1 ...
SPM12: spm_coreg (v6435) 18:24:35 - 24/06/2021
========================================================================
Completed : 18:24:45 - 24/06/2021
Reslicing ...
SPM12: spm_reslice (v5929) 18:24:45 - 24/06/2021
========================================================================
Completed : 18:24:45 - 24/06/2021
Done
Coregistering MNI152_T1_2mm_skull.nii to functional image ...
Coregistering C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\autolabeller\bin\autolabeller\bin\noisecloud\mr\raw\MNI152_T1_2mm_skull.nii to C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\results\classify_ic\nc\rvm_mean_component_ica_s_all_.nii,1 ...
SPM12: spm_coreg (v6435) 18:24:45 - 24/06/2021
========================================================================
Completed : 18:24:51 - 24/06/2021
Reslicing ...
SPM12: spm_reslice (v5929) 18:24:51 - 24/06/2021
========================================================================
Completed : 18:24:51 - 24/06/2021
Done
Reading in spatial tissue maps and atlases...
Extracting features from component 1 of 20
Extracting features from component 2 of 20
Extracting features from component 3 of 20
Extracting features from component 4 of 20
Extracting features from component 5 of 20
Extracting features from component 6 of 20
Extracting features from component 7 of 20
Extracting features from component 8 of 20
Extracting features from component 9 of 20
Extracting features from component 10 of 20
Extracting features from component 11 of 20
Extracting features from component 12 of 20
Extracting features from component 13 of 20
Extracting features from component 14 of 20
Extracting features from component 15 of 20
Extracting features from component 16 of 20
Extracting features from component 17 of 20
Extracting features from component 18 of 20
Extracting features from component 19 of 20
Extracting features from component 20 of 20
Feature extraction complete.
249 total features
20 total networks
Predicting ...
Done
done predicting network
resampling the AAL atlas to input
Coregistering C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\autolabeller\bin\autolabeller\bin\noisecloud\mr\raw\aal2mni152.nii to C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\labeller_test\gift_analysis_nodir\vm_agg__component_ica_.nii,1 ...
SPM12: spm_coreg (v6435) 18:25:49 - 24/06/2021
========================================================================
Completed : 18:26:04 - 24/06/2021
Reslicing ...
SPM12: spm_reslice (v5929) 18:26:04 - 24/06/2021
========================================================================
Completed : 18:26:04 - 24/06/2021
Done
masking AAL atlas
computing correlation
done predicting anatomical labels
resampling to Bucknerlab atlas
resampling the atlas to input
Coregistering C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\autolabeller\bin\autolabeller\data\Functional\Bucknerlab_286_17_networks_plus_anatomy\resampled_mask_Buckner_r286.nii to C:\Users\salman\Dropbox (GSU Dropbox)\projects\autolabeler\testing\labeller_test\gift_analysis_nodir\vm_agg__component_ica_.nii,1 ...
SPM12: spm_coreg (v6435) 18:26:04 - 24/06/2021
========================================================================
Warning: Variable 'r' originally saved as a region cannot be instantiated as an object and will be
read in as a uint32.
> In read_extras (line 23)
In nifti (line 27)
In spm_vol_nifti (line 19)
In spm_vol>spm_vol_hdr (line 128)
In spm_vol (line 61)
In spm_coreg (line 123)
In noisecloud_spm_coregister (line 38)
In label_functional (line 14)
In label_auto_main (line 143)
In autolabel_ic (line 25)
Completed : 18:26:16 - 24/06/2021
Warning: Variable 'r' originally saved as a region cannot be instantiated as an object and will be
read in as a uint32.
> In read_extras (line 23)
In nifti (line 27)
In spm_get_space (line 18)
In noisecloud_spm_coregister (line 45)
In label_functional (line 14)
In label_auto_main (line 143)
In autolabel_ic (line 25)
Warning: Variable 'r' originally saved as a region cannot be instantiated as an object and will be
read in as a uint32.
> In read_extras (line 23)
In nifti (line 27)
In spm_vol_nifti (line 19)
In spm_vol>spm_vol_hdr (line 128)
In spm_vol (line 61)
In noisecloud_spm_coregister (line 57)
In label_functional (line 14)
In label_auto_main (line 143)
In autolabel_ic (line 25)
Reslicing ...
SPM12: spm_reslice (v5929) 18:26:16 - 24/06/2021
========================================================================
Completed : 18:26:16 - 24/06/2021
Done
masking atlas
computing correlation
done predicting functional labels
done reordering FNC
tEnd =
261.2930
Also generated this figure with the FNC plotting script in the src folder:
I am still trying to provision a Mac or roll a virtual machine to figure out the issue with Glmnet. I'll keep you posted.
; (
First, I made sure my script matched the one you ran (except the various tools are already in my path) I replaced the bad mex file, but afterwards the errors looked like what we've seen before. Details below:
>> autolabel_ic
Running the autolabeller on FBIRN training dataset
mask_path =
'/Volumes/Main/Users/dpat/Downloads/nifti_subjects/gift_analysis_nodir/vmMask.nii'
predicting networks
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the
table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
Coregistering /Volumes/Main/Users/dpat/Downloads/nifti_subjects/gift_analysis_nodir/vm_mean_component_ica_s_all_.nii,1 to functional image /usr/local/MATLAB_TOOLS/autolabeller/bin/autolabeller/data/nc_features/fbirn_subxxx_component.nii,1
Coregistering /Volumes/Main/Users/dpat/Downloads/nifti_subjects/gift_analysis_nodir/vm_mean_component_ica_s_all_.nii,1 to /usr/local/MATLAB_TOOLS/autolabeller/bin/autolabeller/data/nc_features/fbirn_subxxx_component.nii,1 ...
SPM12: spm_coreg (v6435) 17:16:46 - 24/06/2021
========================================================================
Completed : 17:16:52 - 24/06/2021
Reslicing ...
SPM12: spm_reslice (v7141) 17:16:53 - 24/06/2021
========================================================================
Completed : 17:16:54 - 24/06/2021
Done
Computing spatial and temporal features of training data ...
Building classifier using logistic regression ...
Running GLMNET (logistic regression with elastic net
K: 10
Grid search for alpha between 0,1 and 1
Type: binomial
Performing cross validated grid search for alpha...
Running fold 1 of 10
Invalid MEX-file '/usr/local/MATLAB_TOOLS/autolabeller/bin/autolabeller/bin/noisecloud/3rdparty/glmnet_matlab/glmnetMex.mexmaci64':
dlopen(/usr/local/MATLAB_TOOLS/autolabeller/bin/autolabeller/bin/noisecloud/3rdparty/glmnet_matlab/glmnetMex.mexmaci64, 6): Library
not loaded: @loader_path/libmex.dylib
Referenced from: /usr/local/MATLAB_TOOLS/autolabeller/bin/autolabeller/bin/noisecloud/3rdparty/glmnet_matlab/glmnetMex.mexmaci64
Reason: image not found
Error in glmnet (line 258)
[a0,ca,ia,nin,dev,alm,nlp,jerr] = glmnetMex(parm,x,y,jd,vp,ne,nx,nlam,flmin,ulam,thresh,isd,nc,maxit,kopt);
Error in noisecloud_glmnetCV (line 81)
fit = glmnet(Xtrain,ytrain,type,options); % Fit model using alpha, train and test specified above
Error in noisecloud_runGlmnetCV (line 26)
REALRESULT = noisecloud_glmnetCV(X,y,K,Lambda,alphav,type);
Error in noisecloud_classify (line 54)
RESULT = noisecloud_runGlmnetCV(features_norm,labels.decision,K,iterations,alphav,Lambda,type,feature_labels);
Error in noisecloud_run (line 127)
result_nc_classifier = noisecloud_classify(features_norm, feature_labels, labels, 'iterations', num_iterations, 'cross_validation',
num_cross_validation, 'threshold', threshold);
Error in label_network_nc (line 95)
[network_pred, fit_mdl, result_nc_classifier] = noisecloud_run(training_opts, testing_opts, 'convert_to_z', 'yes', 'outDir',
outpath, 'coregister', nc_coregister, ...
Error in label_auto_main (line 125)
network_labels = label_network_nc( fullfile( params.outpath, 'nc' ), sesInfo, sm_path, tc_path, params.noise_training_set,
params.threshold );
Error in autolabel_ic (line 27)
label_auto_main( params );
I replaced the mex file glmnetMex.mexmaci64
with the version that came from here: https://github.com/lachioma/glmnet_matlab
>> autolabel_ic
Running the autolabeller on FBIRN training dataset
mask_path =
'/Volumes/Main/Users/dpat/Downloads/nifti_subjects/gift_analysis_nodir/vmMask.nii'
predicting networks
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the
table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
Coregistering /Volumes/Main/Users/dpat/Downloads/nifti_subjects/gift_analysis_nodir/vm_mean_component_ica_s_all_.nii,1 to functional image /usr/local/MATLAB_TOOLS/autolabeller/bin/autolabeller/data/nc_features/fbirn_subxxx_component.nii,1
Coregistering /Volumes/Main/Users/dpat/Downloads/nifti_subjects/gift_analysis_nodir/vm_mean_component_ica_s_all_.nii,1 to /usr/local/MATLAB_TOOLS/autolabeller/bin/autolabeller/data/nc_features/fbirn_subxxx_component.nii,1 ...
SPM12: spm_coreg (v6435) 17:23:28 - 24/06/2021
========================================================================
Completed : 17:23:33 - 24/06/2021
Reslicing ...
SPM12: spm_reslice (v7141) 17:23:34 - 24/06/2021
========================================================================
Completed : 17:23:35 - 24/06/2021
Done
Computing spatial and temporal features of training data ...
Building classifier using logistic regression ...
Running GLMNET (logistic regression with elastic net
K: 10
Grid search for alpha between 0,1 and 1
Type: binomial
Performing cross validated grid search for alpha...
Running fold 1 of 10
One or more output arguments not assigned during call to "glmnetMex".
Error in glmnet (line 258)
[a0,ca,ia,nin,dev,alm,nlp,jerr] = glmnetMex(parm,x,y,jd,vp,ne,nx,nlam,flmin,ulam,thresh,isd,nc,maxit,kopt);
Error in noisecloud_glmnetCV (line 81)
fit = glmnet(Xtrain,ytrain,type,options); % Fit model using alpha, train and test specified above
Error in noisecloud_runGlmnetCV (line 26)
REALRESULT = noisecloud_glmnetCV(X,y,K,Lambda,alphav,type);
Error in noisecloud_classify (line 54)
RESULT = noisecloud_runGlmnetCV(features_norm,labels.decision,K,iterations,alphav,Lambda,type,feature_labels);
Error in noisecloud_run (line 127)
result_nc_classifier = noisecloud_classify(features_norm, feature_labels, labels, 'iterations', num_iterations, 'cross_validation',
num_cross_validation, 'threshold', threshold);
Error in label_network_nc (line 95)
[network_pred, fit_mdl, result_nc_classifier] = noisecloud_run(training_opts, testing_opts, 'convert_to_z', 'yes', 'outDir',
outpath, 'coregister', nc_coregister, ...
Error in label_auto_main (line 125)
network_labels = label_network_nc( fullfile( params.outpath, 'nc' ), sesInfo, sm_path, tc_path, params.noise_training_set,
params.threshold );
Error in autolabel_ic (line 27)
label_auto_main( params );
I tried replacing all three of these with the ones from lachioma's site, but I'm just thrashing now. It did not make any difference.
glmnetMex.mexmaci64 glmnetMex.mexw32 glmnetMex.mexw64
I'm glad you proved the dataset is fine...thank you for continuing to work on the mac issue...it seems like an unacknowledged issue that comes up repeatedly for Macs and Matlab. Let me know if there is anything else I can do. It is cool that it no longer depends on the giant Canlab install!
I also tried the updated files from the Stanford site: https://web.stanford.edu/~hastie/glmnet_matlab/download.html: An updated version compiled on newer versions of Matlab (for Mac OS 11 and Linux): Download. Tested with Matlab 2020b on Mac OS 11 and Matlab 2020a on Linux. I am on Mac 10.15 not 11, so maybe that is the issue?
Following lachioma, I also tried replacing cvglmnet.m with his version. It did not change anything.
I tried wholesale replacing the /usr/local/MATLAB_TOOLS/autolabeller/bin/autolabeller/bin/noisecloud/3rdparty/glmnet_matlab with lachioma's version. This changed the error:
>> autolabel_ic
Running the autolabeller on FBIRN training dataset
mask_path =
'/Volumes/Main/Users/dpat/Downloads/nifti_subjects/gift_analysis_nodir/vmMask.nii'
predicting networks
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the
table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
Coregistering /Volumes/Main/Users/dpat/Downloads/nifti_subjects/gift_analysis_nodir/vm_mean_component_ica_s_all_.nii,1 to functional image /usr/local/MATLAB_TOOLS/autolabeller/bin/autolabeller/data/nc_features/fbirn_subxxx_component.nii,1
Coregistering /Volumes/Main/Users/dpat/Downloads/nifti_subjects/gift_analysis_nodir/vm_mean_component_ica_s_all_.nii,1 to /usr/local/MATLAB_TOOLS/autolabeller/bin/autolabeller/data/nc_features/fbirn_subxxx_component.nii,1 ...
SPM12: spm_coreg (v6435) 18:05:44 - 24/06/2021
========================================================================
Completed : 18:05:49 - 24/06/2021
Reslicing ...
SPM12: spm_reslice (v7141) 18:05:50 - 24/06/2021
========================================================================
Completed : 18:05:51 - 24/06/2021
Done
Computing spatial and temporal features of training data ...
Building classifier using logistic regression ...
Running GLMNET (logistic regression with elastic net
K: 10
Grid search for alpha between 0,1 and 1
Type: binomial
Performing cross validated grid search for alpha...
Running fold 1 of 10
Matrix dimensions must agree.
Error in glmnetPredict (line 274)
nbeta=nbeta(:,lamlist.left).*repmat(lamlist.frac',size(nbeta,1),1)
+nbeta(:,lamlist.right).*(1-repmat(lamlist.frac',size(nbeta,1),1));
Error in noisecloud_glmnetCV (line 84)
Yest = glmnetPredict(fit, 'class', Xtest); % predict the response, result Yest is a M x nLambas matrix
Error in noisecloud_runGlmnetCV (line 26)
REALRESULT = noisecloud_glmnetCV(X,y,K,Lambda,alphav,type);
Error in noisecloud_classify (line 54)
RESULT = noisecloud_runGlmnetCV(features_norm,labels.decision,K,iterations,alphav,Lambda,type,feature_labels);
Error in noisecloud_run (line 127)
result_nc_classifier = noisecloud_classify(features_norm, feature_labels, labels, 'iterations', num_iterations, 'cross_validation',
num_cross_validation, 'threshold', threshold);
Error in label_network_nc (line 95)
[network_pred, fit_mdl, result_nc_classifier] = noisecloud_run(training_opts, testing_opts, 'convert_to_z', 'yes', 'outDir',
outpath, 'coregister', nc_coregister, ...
Error in label_auto_main (line 125)
network_labels = label_network_nc( fullfile( params.outpath, 'nc' ), sesInfo, sm_path, tc_path, params.noise_training_set,
params.threshold );
Error in autolabel_ic (line 27)
label_auto_main( params );
Could you try compiling the mex file using the instruction here- https://web.stanford.edu/~hastie/glmnet_matlab/mac64compile.html ?
Hi Mustafa,
I installed /usr/local/bin/gfortran with brew, but gnu gfortran is no longer supported by Matlab: https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/support/sysreq/files/system-requirements-release-2020b-supported-compilers.pdf
I tried to download Intel Parallel Studio XE Composer Edition for Fortran macOS, but I see no evidence that there is a trial version...and it is very expensive (it requests your license right away during the install).
Is Windows the only environment in which you have tested the software? I have access to Linux machines where I could test.
So I have access to a Mac Big Sur VM now. As you reported, the Glmnet mex is invalid, and we have to compile it. It might take me a while to figure out how to install the Fortran compiler on Mac.
We have developed it in Linux and tested on Windows, so by all means please try it on Linux, I have a feeling it will work :)
Wow, that is fantastic that you got a Mac VM! Big Sur has so many annoying security features, that they may trip you up. https://github.com/growlix/glmnet_matlab is probably the most recent compilation of the mex files I've found...and the compilation process is nicely documented there. Maybe you can figure out how to get a legitimate trial version of the compiler:
I found this helpful (but obviously not helpful enough to solve the problem):
mex -setup -v FORTRAN
Verbose mode is on.
... Looking for compiler 'Intel Fortran Composer XE' ...
... Looking for environment variable 'IFORT_COMPILER20' ...No.
... Looking for environment variable 'IFORT_COMPILER19' ...No.
... Looking for environment variable 'IFORT_COMPILER18' ...No.
... Executing command 'which ifort' ...No.
Did not find installed compiler 'Intel Fortran Composer XE'.
Error using mex
No supported compiler was found. For options, visit https://www.mathworks.com/support/compilers.
I will try on Linux, but probably not today. Maybe it is time for a docker file?
Thanks! Yeah so I had to run some sudo commands so it won't complain as much when running the scripts. Still have to setup the Fortran compiler- and even if we do it may have to be repeated on every different machine. So docker is a great suggestion; I don't have experience with it but I'll look into it. Please let me know how it goes on Linux.
I'm trying a Matlab docker container now (Matlab 2021b on Ubuntu 20). It got a long ways before it complained about not having the Statistics and Machine Learning Toolbox. Our University has a license for that, so I should be able to figure that out. Should this Matlab toolbox be a listed dependency? log_matlab_docker.txt
Right now, yes, the statistics and machine learning toolbox is a dependency. However I think it might be removed. I will look into it.
I have just pushed an update which will remove the dependency. Thanks!
I also found a couple of workarounds for configuring gfortran as the Fortran compiler for Matlab. If possible please give this a try and see if you can compile Glmnet on your end. I will give it a try if I can manage the time.
https://www.mathworks.com/matlabcentral/answers/445505-gfortran-not-found-by-mex-setup https://yingzhouli.com/posts/2017-05/mex-gfortran
Thanks for the change. It looks like one of the links you sent is for linux, and the other is for a much older version of Matlab and the MAC OS. I will give it a try though.
Intel no longer appears to provide their Intel Fortran Composer XE compiler, and the newer Intel oneAPI HPC Toolkit is not supported by Matlab (I've written to Matlab support). My understanding (perhaps flawed) is that the Xcode support is also being removed by Intel.
I've also emailed Srinivas and he is working on a solution which he says he will manage by Wednesday....he asked if I had the stats toolbox...
I'll certainly let you know if I succeed or Srinivas comes up with a good solution.
Hi Mustafa, I finally found a copy of the Intel Fortran compiler and got it working. I have tested the following new MEX file with autolabeller and autolabeller ran to completion! https://www.dropbox.com/s/k6raitw37w7i02d/glmnetMex.mexmaci64?dl=0
Now I turn to trying to understand the output of the autolabeller ; ) -Dianne
Just to throw a wrench in the works, I tried running autolabeller on a GIFT directory that contains subdirectories.
Here's a copy of that GIFT output in dropbox: https://www.dropbox.com/s/2lnj3ucyauy8j7l/gift_analysis.zip?dl=0
autolabeller fails to run correctly on such a directory.
I can fix the problem (and get autolabeller to run through) by copying these two files:
gift_analysis/vm_group_stats_files/mean_component_ica_sall.nii
and
gift_analysis/vm_group_stats_files/mean_timecourses_ica_sall.nii
up to
gift_analysis and renaming them as
vm_mean_timecourses_ica_sall.nii
and
vm_mean_component_ica_sall.nii
So, I'm thinking this is a relatively easy issue for you to fix in your code?
Hi Mustafa, I finally found a copy of the Intel Fortran compiler and got it working. I have tested the following new MEX file with autolabeller and autolabeller ran to completion! https://www.dropbox.com/s/k6raitw37w7i02d/glmnetMex.mexmaci64?dl=0
Now I turn to trying to understand the output of the autolabeller ; ) -Dianne
That's great! I'll put this mex file as a supporting file in the repo. Thank you so much for your contribution!
Just to throw a wrench in the works, I tried running autolabeller on a GIFT directory that contains subdirectories. Here's a copy of that GIFT output in dropbox: https://www.dropbox.com/s/2lnj3ucyauy8j7l/gift_analysis.zip?dl=0
autolabeller fails to run correctly on such a directory.
I can fix the problem (and get autolabeller to run through) by copying these two files: gift_analysis/vm_group_stats_files/mean_component_ica_sall.nii and gift_analysis/vm_group_stats_files/mean_timecourses_ica_sall.nii up to gift_analysis and renaming them as vm_mean_timecourses_ica_sall.nii and vm_mean_component_ica_sall.nii So, I'm thinking this is a relatively easy issue for you to fix in your code?
I think so, probably just need to read it off the parameter file. I will try to put in a fix soon.
Another minor problem: You said you ran the fnc script. I copied that and altered the paths. It works up until line 52 where it tries to find my_icatb_plot_FNC plot_fnc.m.zip.
I spent 20 minutes or so trying to figure out where this variable came from with no success. What am I doing wrong?
Sorry! that is in https://github.com/esalman/autolabeller/tree/master/bin
There's a statement addpath( '../bin/' )
at the beginning of this script which should've taken care of it. I will update to include the full path.
I saw that path but didn't know what to make of it. I just added autolabeller/bin to the path and it worked perfectly! Getting really picky now, README.md says: network_labels.csv Network labels vector (0=artifact, 1=network) and probability that the component/spatial map is a network, but I don't see any probabilities, only the 0-1 labels. Is the documentation wrong, or the result?
Good catch.. Initially we were using a different algorithm (plain logistic regression) to label noise/network, at that time I included the probabilities. Later on we integrated the noisecloud toolbox. It might output some measure of probability but I have to look more into it. I will correct the documentation.
btw I really appreciate all the feedback, I am especially interested in any suggestion you might have to make the outputs more intuitive.
Cool. I think documentation makes a project, and another set of eyes can really help. I've been revisiting GIFT and preparing documentation (https://docs.google.com/document/d/1JUW_rPYYytBRoaRbzHzuCq3oPU4Y-AXdqlcwEE0otj4/edit?usp=sharing). You'll see Appendix H describes using the autolabeller.
This looks great! Srinivas will add the Autolabeller to GIFT, but I think your docs will be very useful. Really appreciate it!
Hi Mustafa, I have filled in Appendix H in https://docs.google.com/document/d/1JUW_rPYYytBRoaRbzHzuCq3oPU4Y-AXdqlcwEE0otj4/edit?usp=sharing with what I hope is an accurate and helpful review of running the autolabeller and understanding the output. I'm hoping you'll have a look. If you'd like to use or modify any of it for your own documentation, feel free.
Here are some suggestions for improving the consistency of the naming strategies and documentation you provide. These are minor suggestions, but I think they might make the tool more approachable by reducing the cognitive load for new users.
The results of running the FNC plots are really helpful:
Hi Mustafa,
Today I am trying to run autolabeller on a real dataset. It has 32 subjects, 4 runs each and 50 ICs.
I am running on the same mac where I worked on the test dataset.
In the script, I changed the paths to the output directory and parameter file.
I get almost to the end:
The Noise vs Signal portion completes, the AAL atlas labels are created, but the functional labels are a problem.
The Matlab paths and software (SPM12, BCT, icatb, and autolabeller) are exactly the same as for the test dataset.
I get this error:
SPM12: spm_reslice (v7141) 14:22:56 - 17/07/2021
========================================================================
Completed : 14:22:56 - 17/07/2021
Done
masking atlas
computing correlation
done predicting functional labels
Index in position 1 exceeds array bounds.
Error in sort_fnc (line 8)
network_fnc = fnc( network_idx, network_idx );
Error in label_auto_main (line 150)
[sorted_idx, network_fnc, order_] = sort_fnc( fnc, func_labels(2:end,1:3) );
Error in autolabel_ic_nad2 (line 27)
label_auto_main( params );
Do you have any idea what I am missing?
Could you please send me these two files if possible-
Thanks Mustafa,
I see that I do not have functional_labels_*.csv
or anatomical_labels_aal.csv
:
I tried rerunning with
params.skip_noise = 1;
params.skip_anatomical = 1;
and I get this error:
>> autolabel_ic_nad2
Running the autolabeller on FBIRN training dataset
Error using readtable (line 245)
Unable to find or open
'/Volumes/Main/Exps/Data/Plante_BIDS/Nifti/derivatives/analysis/gift_nad2/autolabeller_nad2/anatomical_labels_aal.csv'.
Check the path and filename or file permissions.
Error in label_auto_main (line 131)
anat_labels = readtable( fullfile( params.outpath, ['anatomical_labels_'
params.anatomical_atlas '.csv'] ) );
Error in autolabel_ic_nad2 (line 28)
label_auto_main( params );
autolabeller_nad2 % tree
.
├── anatomical_correlations.csv
├── nc
│ ├── nc_class_labels.txt
│ ├── rMNI152_T1_2mm_edges.nii
│ ├── rMNI152_T1_2mm_eye_mask.nii
│ ├── rMNI152_T1_2mm_skull.nii
│ ├── rMNI152_T1_2mm_strucseg.nii
│ ├── raal2mni152.nii
│ ├── rcsf.nii
│ ├── rgrey.nii
│ ├── rnad2_mean_component_ica_s_all_.nii
│ ├── rresampled_mask_Buckner_r286.nii
│ ├── rwhite.nii
│ ├── testing_features.csv
│ └── training_features.csv
└── network_labels.csv
post_process_results attached: nad2_postprocess_results.mat.zip
And here's the script: autolabel_ic_nad2.m.zip
Thanks! Seems there is no issue with the postprocess file, it has the required fnc computed. Could you just try running once with params.skip_anatomical = 0
? I feel that should fix it.
I set these in the script.
params.skip_noise = 1;
params.skip_anatomical = 0;
params.skip_functional = 0;
I did NOT remove the existing autolabeller output directory. I reran and got the same problem.
>> autolabel_ic_nad2
Running the autolabeller on FBIRN training dataset
Error using readtable (line 245)
Unable to find or open
'/Volumes/Main/Exps/Data/Plante_BIDS/Nifti/derivatives/analysis/gift_nad2/autolabeller_nad2/anatomical_labels_aal.csv'.
Check the path and filename or file permissions.
Error in label_auto_main (line 131)
anat_labels = readtable( fullfile( params.outpath, ['anatomical_labels_'
params.anatomical_atlas '.csv'] ) );
Error in autolabel_ic_nad2 (line 28)
label_auto_main( params );
>> autolabel_ic_nad2
Running the autolabeller on FBIRN training dataset
resampling the AAL atlas to input
Coregistering /usr/local/MATLAB_TOOLS/autolabeller/bin/autolabeller/bin/noisecloud/mr/raw/aal2mni152.nii to /Volumes/Main/Exps/Data/Plante_BIDS/Nifti/derivatives/analysis/gift_nad2/nad2_ica_files/agg__component_ica_.nii,1 ...
SPM12: spm_coreg (v6435) 21:21:49 - 17/07/2021
========================================================================
Completed : 21:22:02 - 17/07/2021
Reslicing ...
SPM12: spm_reslice (v7141) 21:22:02 - 17/07/2021
========================================================================
Completed : 21:22:02 - 17/07/2021
Done
masking AAL atlas
computing correlation
done predicting anatomical labels
resampling to Bucknerlab atlas
resampling the atlas to input
Coregistering /usr/local/MATLAB_TOOLS/autolabeller/bin/autolabeller/data/Functional/Bucknerlab_286_17_networks_plus_anatomy/resampled_mask_Buckner_r286.nii to /Volumes/Main/Exps/Data/Plante_BIDS/Nifti/derivatives/analysis/gift_nad2/nad2_ica_files/agg__component_ica_.nii,1 ...
SPM12: spm_coreg (v6435) 21:22:04 - 17/07/2021
========================================================================
Warning: Variable 'r' originally saved as a region cannot be instantiated as an object and will be read in as a uint32.
> In read_extras (line 23)
In nifti (line 27)
In spm_vol_nifti (line 19)
In spm_vol>spm_vol_hdr (line 128)
In spm_vol (line 61)
In spm_coreg (line 123)
In noisecloud_spm_coregister (line 38)
In label_functional (line 14)
In label_auto_main (line 143)
In autolabel_ic_nad2 (line 28)
Completed : 21:22:14 - 17/07/2021
Warning: Variable 'r' originally saved as a region cannot be instantiated as an object and will be read in as a uint32.
> In read_extras (line 23)
In nifti (line 27)
In spm_get_space (line 18)
In noisecloud_spm_coregister (line 45)
In label_functional (line 14)
In label_auto_main (line 143)
In autolabel_ic_nad2 (line 28)
Warning: Variable 'r' originally saved as a region cannot be instantiated as an object and will be read in as a uint32.
> In read_extras (line 23)
In nifti (line 27)
In spm_vol_nifti (line 19)
In spm_vol>spm_vol_hdr (line 128)
In spm_vol (line 61)
In noisecloud_spm_coregister (line 57)
In label_functional (line 14)
In label_auto_main (line 143)
In autolabel_ic_nad2 (line 28)
Reslicing ...
SPM12: spm_reslice (v7141) 21:22:14 - 17/07/2021
========================================================================
Completed : 21:22:14 - 17/07/2021
Done
masking atlas
computing correlation
done predicting functional labels
Index in position 1 exceeds array bounds.
Error in sort_fnc (line 8)
network_fnc = fnc( network_idx, network_idx );
Error in label_auto_main (line 150)
[sorted_idx, network_fnc, order_] = sort_fnc( fnc, func_labels(2:end,1:3) );
Error in autolabel_ic_nad2 (line 28)
label_auto_main( params );
>>
I also removed the autolabeller output directory and retried with allthree parameters set to 0:
params.skip_noise = 0;
params.skip_anatomical = 0;
params.skip_functional = 0;
It dies with the same complaint.
I notice that the FNC dimension in the postprocess file you sent is 32x4x50x50. I assume 50 is the number of components, could you let me know what 32 and 4 indicate?
I have pushed an update handling the multi-session case. Could you please pull the latest code and give it a try? Thanks!
Hi Mustafa,
Your multisession code worked! (the dimensions, as you figured out, I think, were 32 subjects, each with 4 runs)
I only had to update the mex file to run on the mac (could you incorporate that?): https://www.dropbox.com/s/k6raitw37w7i02d/glmnetMex.mexmaci64?dl=0
Thank you!
-Dianne
I will incorporate the mex file, thanks! It might also be worth reaching out to the original Glmnet folks and contributing the mex file compiled on our particular system. I also have your previous feedback on the README in the pipeline, will try to publish it soon.
Oops, I just tried to run plot_fnc and ran into the same problem:
>> plot_fnc_nad2
Index in position 1 exceeds array bounds.
Error in plot_fnc_nad2 (line 39)
fnc = fnc_unsorted(sorted_idx, sorted_idx);
Ah it needed the same fix as the previous one. I have updated the repo, please pull and check again.
Perfect! I updated it and it worked great!
Hi,
I have recently started using GIFT again and read your paper on the autolabeller for noise components with great appreciation! You say that the "pretrained model" is one of the primary contributions of the approach, but I was not able to figure out which file on the github repo (if any) was the pretrained model...or how I might employ that pretrained model.
I'd love to be able to take advantage of this opportunity, but I am having some troubles running the following script:
1) First, I am on Mac OSX Catalina. I had to replace an old Mex file in the Noisecloud 3rd party directory:
Invalid MEX-file '/usr/local/MATLAB_TOOLS/autolabeller/bin/autolabeller/bin/noisecloud/3rdparty/glmnet_matlab/glmnetMex.mexmaci64': I found a substitute here: https://github.com/lachioma/glmnet_matlab and I no longer get explicit complaints about the mex file, so I think it is okay.
2) Autolabeller does not handle a gift analysis directory in which data is stored in subdirectories (e.g., vm_group_stats_files, vm_ica_files etc.). I had to copy
mean_component_ica_s_all.nii
out ofvm_group_stats_files
and relabel it tovm_mean_component_ica_s_all.nii
3) I get partway through the process, and then get an error related to the network labels:
I tried running with the github code, and then tried with the zenodo code (since it contained some different files). I feel like I'm missing an important piece of the puzzle here, and I really hope you can help. I think I'm close. I will keep trying.
Thank you,
Dianne Patterson, Ph.D.