@@ -25,6 +25,19 @@ function combineBaGoLROIs(pathnameR, filesR, pathnameB, filesB, MAPNfile, ...
2525% Cell_02_Results_BaGoL_ROIs.mat
2626% ...
2727%
28+ % You can select _ROIs.mat files for multiple cells and then choose the
29+ % correspnding MAPN ROI files. If all the MAPN ROI files are present, this
30+ % works smoothly. However, if some MAPN ROI files for a particular cell are
31+ % missing, this may result in an error (Inconsistency in Cell #). In this
32+ % situation, run just the single cell with missing MAPN ROIs by itself and all
33+ % will work fine. You can then continue to run multiple cells after this
34+ % cell. For example, suppose there are 7 cells with cell 4 missing some MAPN
35+ % ROIs. Selecting all 7 cells and all MAPN ROIs initially will prodduce the
36+ % error after cell 3 _BaGoL_ROIs.mat is written out. So, run cell 4 again,
37+ % this time by itself, and this time cell 4 _BaGoL_ROIs.mat will be saved.
38+ % Now, select cells 5-7 (and corresponding BaGoL ROIs) and continue processing.
39+ % See also the parameter Keep_numbering below.
40+ %
2841% INPUTS:
2942% pathnameR path to where the ROIs file below are located
3043% filesR _Results_ROIs.mat files to collect ROI info from
@@ -99,7 +112,7 @@ function combineBaGoLROIs(pathnameR, filesR, pathnameB, filesB, MAPNfile, ...
99112 if k <= n_files
100113 fileB = filesB{k };
101114 dataB = load(fullfile(pathnameB , fileB ));
102- % Extract the ROI number and label number from the file name.
115+ % Extract the ROI, label and cell number from the file name.
103116 i = str2num(regexprep(fileB , ' ^.*ROI_([0-9][0-9]).*$' , ' $1' ));
104117 j = str2num(regexprep(fileB , ' ^.*Label_([0-9][0-9]).*$' , ' $1' ));
105118 d = str2num(regexprep(fileB , ' ^.*Cell_([0-9][0-9]).*$' , ' $1' ));
@@ -134,9 +147,17 @@ function combineBaGoLROIs(pathnameR, filesR, pathnameB, filesB, MAPNfile, ...
134147 end
135148 end
136149
137- % Eliminate empty ROIs.
150+ % Print out missing ROIs.
138151 missing = setdiff(1 : n_ROIs , found );
139- if ~keep_numbering && isempty(missing )
152+ if ~isempty(missing )
153+ fprintf(' Cell %d MISSING ROIs:' , c );
154+ for ii = 1 : numel(missing )
155+ fprintf(' %d ' , missing(ii ));
156+ end
157+ fprintf(' \n ' );
158+ end
159+ % Eliminate empty ROIs.
160+ if ~keep_numbering && ~isempty(missing )
140161 RoI_new = cell(n_ROIs - numel(missing ), 1 );
141162 k = 1 ;
142163 for ii = 1 : n_ROIs
@@ -145,6 +166,7 @@ function combineBaGoLROIs(pathnameR, filesR, pathnameB, filesB, MAPNfile, ...
145166 k = k + 1 ;
146167 end
147168 end
169+ k = k - 1 ;
148170 n_ROIs = n_ROIs - numel(missing );
149171 RoI = RoI_new ;
150172 end
0 commit comments