Skip to content

Commit

Permalink
Process extract clusters: support for raw files
Browse files Browse the repository at this point in the history
  • Loading branch information
ftadel committed Mar 2, 2023
1 parent aab5862 commit 91c28a4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion doc/license.html
Expand Up @@ -5,7 +5,7 @@
<body alink="#fff000" link="#fff000" vlink="#fff000">
<h4><span style="font-family: Arial Black; color: #ffffff;"><strong>THERE IS NO UNDO BUTTON!<BR>SET UP A <FONT color=red>BACKUP</FONT> OF YOUR DATABASE</strong></span></h4>
<HR>
<!-- LICENCE_START -->Version: 3.230301 (01-Mar-2023)<br>
<!-- LICENCE_START -->Version: 3.230302 (02-Mar-2023)<br>
<span style="font-style: italic;">COPYRIGHT &copy; 2000-2023
USC &amp; McGill University.<br>
</span>
Expand Down
2 changes: 1 addition & 1 deletion doc/version.txt
@@ -1,2 +1,2 @@
% Brainstorm
% v. 3.230301 (01-Mar-2023)
% v. 3.230302 (02-Mar-2023)
47 changes: 31 additions & 16 deletions toolbox/process/functions/process_extract_cluster.m
Expand Up @@ -26,16 +26,16 @@


%% ===== GET DESCRIPTION =====
function sProcess = GetDescription() %#ok<DEFNU>
function sProcess = GetDescription()
% Description the process
sProcess.Comment = 'Clusters time series';
sProcess.Category = 'Custom';
sProcess.SubGroup = 'Extract';
sProcess.Index = 351;
sProcess.Description = 'https://neuroimage.usc.edu/brainstorm/Tutorials/ChannelClusters';
% Definition of the input accepted by this process
sProcess.InputTypes = {'data'};
sProcess.OutputTypes = {'matrix'};
sProcess.InputTypes = {'raw', 'data'};
sProcess.OutputTypes = {'matrix', 'matrix'};
sProcess.nInputs = 1;
sProcess.nMinFiles = 1;

Expand Down Expand Up @@ -80,7 +80,7 @@


%% ===== RUN =====
function OutputFiles = Run(sProcess, sInputs) %#ok<DEFNU>
function OutputFiles = Run(sProcess, sInputs)
% Initialize returned variable
OutputFiles = {};
% REDIRECTING SCOUT CALLS TO PROCESS_EXTRACT_SCOUTS
Expand Down Expand Up @@ -122,15 +122,7 @@

% ===== LOOP ON THE FILES =====
for iInput = 1:length(sInputs)
sResults = [];

% === READ FILES ===
% Load recordings
sMat = in_bst_data(sInputs(iInput).FileName);
matValues = sMat.F;
stdValues = sMat.Std;
% Input filename
condComment = sInputs(iInput).FileName;
% === READ CHANNEL FILE ===
% Check for channel file
if isempty(sInputs(iInput).ChannelFile)
bst_report('Error', sProcess, sInputs(iInput), 'This process requires a channel file.');
Expand All @@ -143,8 +135,31 @@
return;
end

% === READ RECORDINGS ===
% Load data file
sMat = in_bst_data(sInputs(iInput).FileName);
% Raw file
isRaw = strcmpi(sInputs(iInput).FileType, 'raw');
if isRaw
% Convert time bounds into samples
sFile = sMat.F;
if ~isempty(TimeWindow)
SamplesBounds = round(sFile.prop.times(1) .* sFile.prop.sfreq) + bst_closest(TimeWindow, sMat.Time) - 1;
else
SamplesBounds = [];
end
% Read data
[matValues, sMat.Time] = in_fread(sFile, ChannelMat, 1, SamplesBounds, []);
stdValues = [];
% Remember that time selection is already applied
TimeWindow = [];
% Epoched data file
else
matValues = sMat.F;
stdValues = sMat.Std;
end
% Nothing loaded
if isempty(sMat) || (isempty(matValues) && (isempty(sResults) || ~isfield(sResults, 'ImagingKernel') || isempty(sResults.ImagingKernel)))
if isempty(sMat) || isempty(matValues)
bst_report('Error', sProcess, sInputs(iInput), 'Could not load anything from the input file. Check the requested time window.');
return;
end
Expand Down Expand Up @@ -272,9 +287,9 @@
scoutStds = cat(1, scoutStds, tmpStd);
for iRow = 1:size(tmpScout,1)
if ~isempty(RowNames)
Description = cat(1, Description, [sClusters(iClust).Label '.' RowNames{iRow} ' @ ' condComment]);
Description = cat(1, Description, [sClusters(iClust).Label '.' RowNames{iRow} ' @ ' sInputs(iInput).FileName]);
else
Description = cat(1, Description, [sClusters(iClust).Label ' @ ' condComment]);
Description = cat(1, Description, [sClusters(iClust).Label ' @ ' sInputs(iInput).FileName]);
end
end
end
Expand Down

0 comments on commit 91c28a4

Please sign in to comment.