Authored by Anthony Boyer

### Fix so it skips crops with <2s baseline

Showing with 14 additions and 2 deletions
 @@ -74,6 +74,9 @@ function ImaGIN_SpikesDetection(S) @@ -74,6 +74,9 @@ function ImaGIN_SpikesDetection(S) 74 empty_series = find(series_length == 0); 74 empty_series = find(series_length == 0); 75 nonempty_series = find(series_length); 75 nonempty_series = find(series_length); 76 valid_length = series_length(nonempty_series); 76 valid_length = series_length(nonempty_series); 77 + if isempty(valid_length) % If valid_length is empty that means there are no extracted baselines in any channels for this stimulation (baseline is too short). 78 + valid_length = 1; 79 + end 77 if all(valid_length == valid_length(1)) 80 if all(valid_length == valid_length(1)) 78 for ee=1:numel(empty_series) 81 for ee=1:numel(empty_series) 79 channels.(global_montage{empty_series(ee)}).timeserie{ff,:} = zeros(1,valid_length(1)); 82 channels.(global_montage{empty_series(ee)}).timeserie{ff,:} = zeros(1,valid_length(1)); @@ -89,8 +92,17 @@ function ImaGIN_SpikesDetection(S) @@ -89,8 +92,17 @@ function ImaGIN_SpikesDetection(S) 89 for nn=1:numel(global_montage) 92 for nn=1:numel(global_montage) 90 channel{nn} = global_montage{nn}; 93 channel{nn} = global_montage{nn}; 91 timeseries(nn,:) = [channels.(global_montage{nn}).timeserie{:}]; 94 timeseries(nn,:) = [channels.(global_montage{nn}).timeserie{:}]; 92 - zeroed(nn,:) = [channels.(global_montage{nn}).zeroed{:}]; 93 - coordinates(nn,:) = channels.(global_montage{nn}).coordinates{1,:}; 95 + zeroed(nn,:) = [channels.(global_montage{nn}).zeroed{:}]; 96 + all_coordinates = cell2mat(channels.(global_montage{nn}).coordinates(:)); 97 + [lines cols] = find(~isnan(all_coordinates)); 98 + coordinates_with_values = all_coordinates(unique(lines),:); 99 + if isempty(coordinates_with_values) 100 + coordinates(nn,:) = NaN(1,3); 101 + elseif sum(all(coordinates_with_values == coordinates_with_values(1,:))) == 3 102 + coordinates(nn,:) = coordinates_with_values(1,:); 103 + else 104 + error('Inconsistent electrodes coordinates between cropped files.'); 105 + end 94 end 106 end 95 % Create the new sensor 107 % Create the new sensor 96 new_sensors_info.balance.current = 'none'; 108 new_sensors_info.balance.current = 'none';