Skip to content

Commit 8fd1d55

Browse files
authored
v1.81.4 -- Fix issue found by Meryem, where prune channels doesn't work correctly in hmrMotionArtifact.m. (#187)
* v1.81.3 -- Fix failure to load full head probe fullhead_56x144_v3.SD or ninjaNIRS2022_2023-09-19-18-26-16.snirf files because SnirfClass.GetAuxDataMatrix gets an error when resampling with Matlab's resample function which does not handle a huge difference between aux sample rate and the data sample rate. To fix added local resample function resamplee.m to avoid this issue. DataTree, v1.17.3 -- Fix failure to load full head probe fullhead_56x144_v3.SD or ninjaNIRS2022_2023-09-19-18-26-16.snirf files because SnirfClass.GetAuxDataMatrix gets an error when resampling with Matlab's resample function which does not handle a huge difference between aux sample rate and the data sample rate. To fix added local resample function resamplee.m to avoid this issue. Utils, v1.8.1 -- Fix in ImageRecon error when setting timerange, such that it is more than or less that tHRF. Fix is to get tHRF when ImageRecon GUI launches and use ceiln and floorn for min and max tHRF to make sure it is not out of range. Added floorn.m and ceiln.m to fix this. -- Fix failure to load full head probe fullhead_56x144_v3.SD or ninjaNIRS2022_2023-09-19-18-26-16.snirf files because SnirfClass.GetAuxDataMatrix gets an error when resampling with Matlab's resample function which does not handle a huge difference between aux sample rate and the data sample rate. To fix added local resample function resamplee.m to avoid this issue. * v1.81.4 -- Fix issue found by Meryem, where prune channels doesn't work correctly in hmrMotionArtifact.m because combining mlActAuto and mlActMan isn't done correctly such that manual prunning is erased by auto pruning. Add function mlAct_CombineIndexLists to solve issue. Same issue in hmrR_MotionArtifactByChannel.m and hmrR_MotionCorrectWavelet.m. -- Make hmrR_PruneChannels.m user parameters drange and SNRthresh greater precision FuncRegistry, v1.4.2 -- Fix issue found by Meryem, where prune channels doesn't work correctly in hmrMotionArtifact.m because combining mlActAuto and mlActMan isn't done correctly such manual prunning is erased by auto pruning. Same issue in hmrR_MotionArtifactByChannel.m and hmrR_MotionCorrectWavelet.m. -- Make hmrR_PruneChannels.m user parameters drange and SNRthresh greater precision DataTree, v1.17.4 -- Fix probe not displaying in Homer3 because probe.sourcePos2D and probe.detectorPos2D are all zeros (which signifies empty but is not detected as empty) instead of actually empty. Also try to make units for generated 2D probe same as 3D by calling new method ProbeClass.ScaleProjection2D() -- Fix AuxClass eq function to check for different dataTimeSeries sizes when checking if 2 AuxClass objects are equal
1 parent d257c0b commit 8fd1d55

19 files changed

+98
-27
lines changed

DataTree/AcquiredData/Snirf/AuxClass.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ function Copy(obj, obj2)
196196
if ~strcmp(obj.name, obj2.name)
197197
return;
198198
end
199+
if ~all(size(obj.dataTimeSeries)==size(obj2.dataTimeSeries))
200+
return;
201+
end
202+
if ~all(size(obj.time)==size(obj2.time))
203+
return;
204+
end
199205
if ~all(obj.dataTimeSeries(:)==obj2.dataTimeSeries(:))
200206
return;
201207
end

DataTree/AcquiredData/Snirf/ProbeClass.m

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,40 @@ function BackwardCompatibility(obj)
150150

151151

152152

153+
% -------------------------------------------------------
154+
function ScaleProjection2D(obj)
155+
if size(obj.sourcePos2D,1)
156+
dm_src2d = distmatrix([obj.sourcePos2D, zeros(size(obj.sourcePos2D,1),1)]);
157+
else
158+
dm_src2d = distmatrix(obj.sourcePos2D, zeros);
159+
end
160+
dm_src3d = distmatrix(obj.sourcePos3D);
161+
exp = round(log10(mean(dm_src3d(dm_src3d(:)>0)))) - round(log10(mean(dm_src2d(dm_src2d(:)>0))));
162+
scaleFactor = 10^exp;
163+
obj.sourcePos2D = obj.sourcePos2D*scaleFactor;
164+
165+
if size(obj.detectorPos2D,1)
166+
dm_det2d = distmatrix([obj.detectorPos2D, zeros(size(obj.detectorPos2D,1),1)]);
167+
else
168+
dm_det2d = distmatrix(obj.detectorPos2D, zeros);
169+
end
170+
dm_det3d = distmatrix(obj.detectorPos3D);
171+
exp = round(log10(mean(dm_det3d(dm_det3d(:)>0)))) - round(log10(mean(dm_det2d(dm_det2d(:)>0))));
172+
scaleFactor = 10^exp;
173+
obj.detectorPos2D = obj.detectorPos2D*scaleFactor;
174+
end
175+
176+
177+
178+
153179
% -------------------------------------------------------
154180
function Project_3D_to_2D(obj)
181+
if all(obj.sourcePos2D(:)==0)
182+
obj.sourcePos2D = [];
183+
end
184+
if all(obj.detectorPos2D(:)==0)
185+
obj.detectorPos2D = [];
186+
end
155187
if isempty(obj.sourcePos2D) && isempty(obj.detectorPos2D)
156188
if isempty(obj.landmarkPos3D) || ~obj.isValidLandmarkLabels()
157189
nSource = size(obj.sourcePos3D,1);
@@ -220,6 +252,7 @@ function Project_3D_to_2D(obj)
220252
%
221253
obj.sourcePos2D = convert_optodepos_to_circlular_2D_pos(obj.sourcePos3D, T, norm_factor);
222254
obj.detectorPos2D = convert_optodepos_to_circlular_2D_pos(obj.detectorPos3D, T, norm_factor);
255+
obj.ScaleProjection2D();
223256
end
224257
end
225258
end

DataTree/AcquiredData/Snirf/SnirfClass.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,11 @@ function SetMetaDataTags(obj, val)
11781178
p = length(obj2.GetTime());
11791179
q = length(obj.aux(ii).GetTime());
11801180
end
1181-
datamat(:,ii) = resample(obj.aux(ii).GetDataTimeSeries(), p, q);
1181+
m = resamplee(obj.aux(ii).GetDataTimeSeries(), p, q);
1182+
if isrow(m)
1183+
m = m';
1184+
end
1185+
datamat = [datamat, m]; %#ok<AGROW>
11821186
end
11831187
end
11841188

DataTree/Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.17.2
1+
1.17.4

FuncRegistry/UserFunctions/hmrR_MotionArtifact.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@
9999
% Get list of active channels
100100
mlActMan{iBlk} = mlAct_Initialize(mlActMan{iBlk}, MeasList);
101101
mlActAuto{iBlk} = mlAct_Initialize(mlActAuto{iBlk}, MeasList);
102-
lstAct1 = mlAct_Matrix2IndexList(mlActAuto{iBlk}, MeasList);
103-
lstAct2 = mlAct_Matrix2IndexList(mlActMan{iBlk}, MeasList);
104-
lstAct = unique([lstAct1(:)', lstAct2(:)']);
102+
lstAct = mlAct_CombineIndexLists( mlActMan{iBlk}, mlActAuto{iBlk}, MeasList );
105103

106104
if length(fs)~=1
107105
fs = 1/(fs(2)-fs(1));

FuncRegistry/UserFunctions/hmrR_MotionArtifactByChannel.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@
108108
% get list of active channels
109109
mlActMan{iBlk} = mlAct_Initialize(mlActMan{iBlk}, MeasList);
110110
mlActAuto{iBlk} = mlAct_Initialize(mlActAuto{iBlk}, MeasList);
111-
lstAct1 = mlAct_Matrix2IndexList(mlActAuto{iBlk}, MeasList);
112-
lstAct2 = mlAct_Matrix2IndexList(mlActMan{iBlk}, MeasList);
113-
lstAct = unique([lstAct1(:)', lstAct2(:)']);
111+
lstAct = mlAct_CombineIndexLists( mlActMan{iBlk}, mlActAuto{iBlk}, MeasList );
114112

115113
% set artifact buffer for tMask seconds on each side of spike
116114
art_buffer = round(tMask*fs); % time in seconds times sample rate

FuncRegistry/UserFunctions/hmrR_MotionCorrectWavelet.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@
7070

7171
mlActMan{iBlk} = mlAct_Initialize(mlActMan{iBlk}, MeasList);
7272
mlActAuto{iBlk} = mlAct_Initialize(mlActAuto{iBlk}, MeasList);
73-
lstAct1 = mlAct_Matrix2IndexList(mlActAuto{iBlk}, MeasList);
74-
lstAct2 = mlAct_Matrix2IndexList(mlActMan{iBlk}, MeasList);
75-
lstAct = unique([lstAct1(:)', lstAct2(:)']);
73+
lstAct = mlAct_CombineIndexLists( mlActMan{iBlk}, mlActAuto{iBlk}, MeasList );
7674

7775
SignalLength = size(dod,1); % #time points of original signal
7876
N = ceil(log2(SignalLength)); % #of levels for the wavelet decomposition

FuncRegistry/UserFunctions/hmrR_PruneChannels.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
% Prune_Channels: mlActAuto = hmrR_PruneChannels(data, probe, mlActMan, tIncMan, dRange, SNRthresh, SDrange)
3131
%
3232
% PARAMETERS:
33-
% dRange: [1e4, 1e7]
34-
% SNRthresh: 2
33+
% dRange: [1.0e4, 1.0e7]
34+
% SNRthresh: 2.0
3535
% SDrange: [0.0, 45.0]
3636
%
3737
% TO DO:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function lstAct = mlAct_CombineIndexLists( mlAct1, mlAct2, ml )
2+
3+
lstAct1 = mlAct_Matrix2IndexList(mlAct1, ml);
4+
lstAct2 = mlAct_Matrix2IndexList(mlAct2, ml);
5+
lstAct = [lstAct1(:)', lstAct2(:)'];
6+
7+
k = find(ismember(lstAct,lstAct1) & ismember(lstAct,lstAct2));
8+
lstAct = unique(lstAct(k));
9+

FuncRegistry/Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.1
1+
1.4.2

UnitTests/FindUnitTestsFolders.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function groupFolders = FindUnitTestsFolders()
22
global logger
3-
global SCRAMBLE
3+
global SCRAMBLE_CHANNELS
44

55
logger = InitLogger(logger);
66

@@ -22,7 +22,7 @@
2222
groupFolders{kk} = dirs(ii).name;
2323
logger.Write('Found unit test folder %s\n', pathfull);
2424

25-
if SCRAMBLE
25+
if SCRAMBLE_CHANNELS
2626
ScrambleChannelsForGroup(pathfull);
2727
end
2828
kk = kk+1;

UnitTests/UnitTests_Init.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function UnitTests_Init(standalone, start, appname)
66
global logger
77
global cfg
88
global maingui
9-
global SCRAMBLE
9+
global SCRAMBLE_CHANNELS
1010
global ERROR_ODDS_CONST
1111

1212
if ~exist('standalone','var') || isempty(standalone)
@@ -44,7 +44,7 @@ function UnitTests_Init(standalone, start, appname)
4444
reg = RegistriesClass();
4545
reg.DeleteSaved();
4646

47-
SCRAMBLE = true;
47+
SCRAMBLE_CHANNELS = true;
4848
ERROR_ODDS_CONST = generateErrorOddsConstant(0);
4949
end
5050

Utils/Shared/Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.8.0
1+
1.8.1

Utils/Shared/ceiln.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function val = ceiln(val0, n)
2+
if ~exist('n','var')
3+
n = 0;
4+
end
5+
pw = ceil(log10(abs(val0))); % Find order of magnitude of val.
6+
res = 10^(pw-n-2); % Resolution to round to.
7+
valtemp = val0*res;
8+
val = ceil(valtemp)/res; % < change floor() to ceil(), for ceiling equivalent.

Utils/Shared/floorn.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function val = floorn(val0, n)
2+
if ~exist('n','var')
3+
n = 0;
4+
end
5+
pw = ceil(log10(abs(val0))); % Find order of magnitude of val.
6+
res = 10^(pw-n-2); % Resolution to round to.
7+
valtemp = val0*res;
8+
val = floor(valtemp)/res; % < change floor() to ceil(), for ceiling equivalent.
9+

Utils/Shared/getAppDir.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@
7575
else
7676
dirname = fileparts(which('Homer3.m'));
7777
end
78-
78+
if ~ispathvalid(dirname)
79+
dirname = filesepStandard(pwd);
80+
end
7981
dirname(dirname=='\') = '/';
8082
if dirname(end) ~= '/'
8183
dirname(end+1) = '/';

Utils/Shared/pretty_print_struct.m

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function pretty_print_struct(st, indent, option, logger)
1+
function pretty_print_struct(st, indent, option)
22
spaces = '';
33

44
if ~exist('st','var') || isempty(st)
@@ -10,18 +10,14 @@ function pretty_print_struct(st, indent, option, logger)
1010
if ~exist('option','var') || isempty(option)
1111
option = 1;
1212
end
13-
if ~exist('logger','var')
14-
logger = [];
15-
end
16-
logger = InitLogger(logger);
17-
1813
if iswholenum(indent)
1914
spaces = blanks(indent);
2015
elseif ischar(indent)
2116
spaces = blanks(length(indent));
2217
end
2318

2419
if isstruct(st) || isobject(st)
20+
fields = properties(st);
2521
s = evalc('disp(st)');
2622
c = str2cell_fast(s, char(10));
2723
for ii=1:length(c)

Utils/Shared/resamplee.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function resig = resamplee(sig,upsample,downsample)
2+
if upsample*downsample<2^31
3+
resig = resample(sig,upsample,downsample);
4+
else
5+
sig1half = sig(1:floor(length(sig)/2));
6+
sig2half = sig(floor(length(sig)/2):end);
7+
resig1half = resamplee(sig1half, floor(upsample/2), length(sig1half));
8+
resig2half = resamplee(sig2half, upsample-floor(upsample/2), length(sig2half));
9+
resig = [resig1half(:); resig2half(:)];
10+
end

Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.81.2
1+
1.81.4

0 commit comments

Comments
 (0)