Skip to content

Commit

Permalink
Bug fix: Load kernel source files attached to raw recordings
Browse files Browse the repository at this point in the history
  • Loading branch information
ftadel committed Sep 10, 2019
1 parent b707680 commit 5d9d100
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion doc/license.html
Expand Up @@ -3,7 +3,7 @@

</head>
<body alink="#fff000" link="#fff000" vlink="#fff000">
<!-- LICENCE_START -->Version: 3.190907 (07-Sep-2019)<br>
<!-- LICENCE_START -->Version: 3.190910 (10-Sep-2019)<br>
<span style="font-style: italic;">COPYRIGHT &copy; 2000-2019
USC &amp; McGill University.<br>
</span>
Expand Down
22 changes: 18 additions & 4 deletions toolbox/core/bst_memory.m
Expand Up @@ -1010,7 +1010,7 @@ function ReloadStatDataSets() %#ok<DEFNU>
% Get variables list
File_whos = whos('-file', ResultsFullFile);

% ===== Is Result file is already loaded ? ====
% ===== Is Result file is already loaded ? ====
% If Result file is dependent from a Data file
if ~isempty(DataFile)
% Load (or simply get) DataSet associated with DataFile
Expand Down Expand Up @@ -1042,11 +1042,18 @@ function ReloadStatDataSets() %#ok<DEFNU>
GlobalData.DataSet(iDS).StudyFile = file_short(sStudy.FileName);

% === NORMAL RESULTS FILE ===
NumberOfSamples = [];
SamplingRate = [];
if any(strcmpi('ImageGridAmp', {File_whos.name}))
% Load results .Mat
ResultsMat = in_bst_results(ResultsFullFile, 0, 'Comment', 'Time', 'ChannelFlag', 'SurfaceFile', 'HeadModelType', 'ColormapType', 'DisplayUnits', 'GoodChannel', 'Atlas');
% Raw file: Use only the loaded time window
if ~isempty(DataFile) && strcmpi(GlobalData.DataSet(iDS).Measures.DataType, 'raw') && ~isempty(strfind(ResultsFullFile, '_KERNEL_'))
Time = GlobalData.DataSet(iDS).Measures.Time;
NumberOfSamples = GlobalData.DataSet(iDS).Measures.NumberOfSamples;
SamplingRate = GlobalData.DataSet(iDS).Measures.SamplingRate;
% If Time does not exist, try to rebuild it
if isempty(ResultsMat.Time)
elseif isempty(ResultsMat.Time)
% If DataSet.Measures is empty (if no data was loaded)
if isempty(GlobalData.DataSet(iDS).Measures.Time)
% It is impossible to reconstruct the time vector => impossible to load ResultsFile
Expand Down Expand Up @@ -1080,6 +1087,13 @@ function ReloadStatDataSets() %#ok<DEFNU>
if (length(Time) == 1)
Time = [0,0.001] + Time;
end
% Sampling rate and number of samples
if isempty(NumberOfSamples)
NumberOfSamples = length(Time);
end
if isempty(SamplingRate)
SamplingRate = Time(2)-Time(1);
end

% ===== LOAD CHANNEL FILE =====
if ~isempty(ChannelFile)
Expand All @@ -1096,8 +1110,8 @@ function ReloadStatDataSets() %#ok<DEFNU>
Results.SurfaceFile = ResultsMat.SurfaceFile;
Results.Comment = ResultsMat.Comment;
Results.Time = Time([1, end]);
Results.NumberOfSamples = length(Time);
Results.SamplingRate = Time(2)-Time(1);
Results.NumberOfSamples = NumberOfSamples;
Results.SamplingRate = SamplingRate;
Results.ColormapType = ResultsMat.ColormapType;
Results.DisplayUnits = ResultsMat.DisplayUnits;
Results.Atlas = ResultsMat.Atlas;
Expand Down
2 changes: 1 addition & 1 deletion toolbox/gui/panel_record.m
Expand Up @@ -1099,7 +1099,7 @@ function ReloadRecordings(isForced)
GlobalData.DataSet(iDS).Measures.NumberOfSamples = smpLength;
% Update linked result files
for iRes = 1:length(GlobalData.DataSet(iDS).Results)
if strcmpi(file_gettype(GlobalData.DataSet(iDS).Results(iRes).FileName), 'link')
if strcmpi(file_gettype(GlobalData.DataSet(iDS).Results(iRes).FileName), 'link') || ~isempty(strfind(GlobalData.DataSet(iDS).Results(iRes).FileName, '_KERNEL_'))
GlobalData.DataSet(iDS).Results(iRes).Time = newTimeWindow;
GlobalData.DataSet(iDS).Results(iRes).NumberOfSamples = smpLength;
end
Expand Down

0 comments on commit 5d9d100

Please sign in to comment.