Skip to content

Commit

Permalink
add save file option and LEC region
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanharvey1 committed Dec 6, 2024
1 parent 8d73f13 commit 51c69b9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lfp/detect_delta_waves.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function detect_delta_waves(varargin)
addParameter(p, 'channel', [], @isnumeric);
addParameter(p, 'peak_to_trough_ratio', 3, @isnumeric); % legacy name for "threshold"
addParameter(p, 'threshold', 3, @isnumeric);
addParameter(p, 'brainRegion', {'PFC', 'MEC', 'EC', 'ILA', 'PL', 'Cortex'}, @(x) any(iscell(x), iscchar(x)));
addParameter(p, 'brainRegion', {'PFC', 'MEC', 'LEC', 'EC', 'ILA', 'PL', 'Cortex'}, @(x) any(iscell(x), iscchar(x)));
addParameter(p, 'manual_pick_channel', false, @islogical);
addParameter(p, 'use_sleep_score_delta_channel', false, @islogical);
addParameter(p, 'EMG_threshold', 0.6, @isnumeric);
Expand All @@ -88,6 +88,8 @@ function detect_delta_waves(varargin)
addParameter(p, 'verify_firing', true, @islogical);
addParameter(p, 'ignore_intervals', [], @isnumeric);
addParameter(p, 'forceDetect', false, @islogical);
addParameter(p, 'save_filename', 'deltaWaves', @ischar);


parse(p, varargin{:})
basepath = p.Results.basepath;
Expand Down Expand Up @@ -119,13 +121,14 @@ function run(basepath, p)
verify_firing = p.Results.verify_firing;
ignore_intervals = p.Results.ignore_intervals;
forceDetect = p.Results.forceDetect;
save_filename = p.Results.save_filename;

disp(basepath)

basename = basenameFromBasepath(basepath);

% check if file aready exists
event_file = fullfile(basepath, [basename, '.deltaWaves.events.mat']);
event_file = fullfile(basepath, [basename, '.', save_filename, '.events.mat']);
if exist(event_file, "file") && ~forceDetect
% verify file contains minimum fields (timestamps, peaks)
load(event_file, 'deltaWaves')
Expand Down Expand Up @@ -277,6 +280,10 @@ function run(basepath, p)
EMG = getStruct(basepath, 'EMG');
immobility = EMG.timestamps(FindInterval(EMG.data < EMG_threshold));
immobility(diff(immobility, [], 2) < 1, :) = [];
% reshape interval if needed
if size(immobility,2) == 1
immobility = immobility';
end
else
immobility = [-inf, inf];
end
Expand Down Expand Up @@ -332,11 +339,11 @@ function run(basepath, p)
colormap("parula")
end
else
verify_firing = false;
verify_firing = false;
warning("no cortical cells, impossible to verify firing");
end
catch
verify_firing = false;
verify_firing = false;
warning("problem loading cortical cell spiking, impossible to verify firing");
end
end
Expand Down

0 comments on commit 51c69b9

Please sign in to comment.