help > Potential bug (and fix) in conn_annot2nii for mismatched number of lh/rh ROIs
Jun 19, 2024  07:06 PM | tposside
Potential bug (and fix) in conn_annot2nii for mismatched number of lh/rh ROIs

Hi there,


I'm using Conn 22a.


I was inputting my own ROIs into Conn from freesurfer lh/rh.ROI.annot files and noticed that if the lh and rh annot files did not have the same ROIs, conn_annot2nii would hit an indexing error. For example, if the lh.ROI.annot file contained 12 ROIs but the rh.ROI.annot file was missing one of those ROIs it would hit an indexing error on line 100 of conn_annot2nii. 


conn_annot2nii already had some code to handle this exact situation (if/else statement starting on line 88):


if isequal(log.labels{ifile(1)},log.labels{ifile(2)})
        names_rois=[cellfun(@(x)[x ' (L)'],names_rois,'uni',0); cellfun(@(x)[x ' (R)'],names_rois,'uni',0)];
 else 
        %names_rois=[log.labels{ifile(1)}; log.labels{ifile(2)}];
        names_rois=[cellfun(@(x)[x ' (L)'],regexprep(log.labels{ifile(1)},'^l\.','','ignorecase'),'uni',0); cellfun(@(x)[x '        (R)'],regexprep(log.labels{ifile(1)},'^r\.','','ignorecase'),'uni',0)];
 end


But it works improperly because in the else statement you are indexing 1 of ifile (lh) for both lh and rh. So it should be:


names_rois=[cellfun(@(x)[x ' (L)'],regexprep(log.labels{ifile(1)},'^l\.','','ignorecase'),'uni',0); cellfun(@(x)[x '        (R)'],regexprep(log.labels{ifile(2)},'^r\.','','ignorecase'),'uni',0)];


With this change I think it works as intended. 


Let me know if this is indeed a bug and the correct fix for it.


Thanks!

Threaded View

TitleAuthorDate
Potential bug (and fix) in conn_annot2nii for mismatched number of lh/rh ROIs
tposside Jun 19, 2024
tposside Jun 21, 2024
Alfonso Nieto-Castanon Jun 19, 2024