Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve signal quality check #254

Merged
merged 17 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
sProcess.Comment = 'Scalp Coupling Index';
sProcess.Category = 'Custom';
sProcess.SubGroup = {'NIRS', 'Pre-process'};
sProcess.Index = 1201;
sProcess.Index = 0;
sProcess.isSeparator = 0;
sProcess.Description = 'https://github.com/Nirstorm/nirstorm/wiki/Scalp-coupling-index';

Expand Down Expand Up @@ -61,6 +61,9 @@
end

function OutputFiles = Run(sProcess, sInputs)

warning('This process has been deprecated. Use Signal Quality Control instead')

OutputFiles = {};
for iInput=1:length(sInputs)
% Load recordings
Expand Down
33 changes: 15 additions & 18 deletions bst_plugin/preprocessing/process_nst_detect_bad.m
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@
channel_flags = sData.ChannelFlag;
nirs_flags = strcmpi({channel_def.Channel.Type}, 'NIRS');

signal=sData.F';
nirs_signal=signal(:,nirs_flags);
signal = sData.F';
nirs_signal = signal(:,nirs_flags);

nb_chnnels=size(signal,2);
nb_sample= size(signal,1);
nb_chnnels = size(signal,2);
nb_sample = size(signal,1);


% Remove negative channel
Expand All @@ -282,11 +282,12 @@

% Remove channel with low SCI or power
if options.option_sci.Value
fs = 1 / diff(sData.Time(1:2));
[SCI, power] = process_nst_sci('compute',nirs_signal',channel_def.Channel(nirs_flags), fs);

window_length = 10;
[~, SCI, power] = process_nst_quality_check('compute_SCI', sData.Time, nirs_signal', window_length, channel_def.Channel(nirs_flags));

SCI = SCI *100;
power = power*100;
SCI = median(SCI,2) * 100;
power = median(power,2) * 100;

SCI_threshold = options.sci_threshold.Value{1};
SCI_channels = false(1,nb_chnnels);
Expand Down Expand Up @@ -325,18 +326,14 @@
% Remove channel with high CV
if options.option_coefficient_variation.Value
CV_threshold = options.coefficient_variation.Value{1};
low_cutoff = 1/200;
high_cutoff = 0.1;
order = 2;
fs = 1 / diff(sData.Time(1:2));

[nirs_filtered, transient] = process_nst_iir_filter('Compute',nirs_signal(100:end,:), fs, 'bandpass', low_cutoff, ...
high_cutoff, order, 1);

CV = std(nirs_filtered,1,'omitnan')./mean(nirs_filtered,1).*100;

window_length = 1000;
[~, CV ] = process_nst_quality_check('compute_CV', sData.Time, nirs_signal', window_length);

CV = median(CV,2) * 100;

CV_channels = false(1,nb_chnnels);
CV_channels(nirs_flags) = CV>CV_threshold ;
CV_channels(nirs_flags) = CV > CV_threshold ;

channel_flags(CV_channels) = -1;
criteria(end+1,:)= {'high coeffience variation channels', CV_channels,{}};
Expand Down
Loading