Skip to content

Commit de3e330

Browse files
committed
v1.80.7
DataTree, v1.16.1, v1.16.0 -- Fix SnirfClass.Save() not saving 3D landmarks and labels. Reproduce with fullhead_56x144_v2.SD. The conversion from SD to Snirf is getting confused: In the SD file the SD.Landmarks3D is empty, which is why it is making the Snirf probe.landmarksPos3D empty. (That is, it is assigning probe.landmarksPos3D from SD.Landmarks3D) However: SD.Landmarks have the actual 3D coordinates. Added code to look for 3D positions (checking that they are actually 3D and not 2D) in SD.Landmarks if SD.Landmarks3D is empty. -- Fix error in NirsClass equal compare where ProbeEqual method is not checking size of SD.MeasList fields before comparing content causing exception when SD.MeasList is not same sizes -- Fix aux conversion from SNIRF aux with different time bases to NirsClass aux Utils, 1.8.0 -- Avoid looking in Install folder for the AppSettings.cfg files
1 parent a1fa37c commit de3e330

File tree

6 files changed

+108
-34
lines changed

6 files changed

+108
-34
lines changed

DataTree/AcquiredData/Nirs/NirsClass.m

Lines changed: 97 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
if ~ischar(varargin{1}) && nargin==1
7777
obj.ErrorCheck();
7878
return
79-
end
79+
end
8080

8181
if nargin==2
8282
obj.SetDataStorageScheme(varargin{2});
@@ -238,8 +238,12 @@ function SortData(obj)
238238

239239
% ---------------------------------------------------------
240240
function err = LoadProbeMeasList(obj, fdata, err)
241-
if isproperty(fdata,'SD')
242-
obj.CopyProbe(fdata.SD);
241+
SD = fdata;
242+
while isproperty(SD,'SD')
243+
SD = SD.SD;
244+
end
245+
if isproperty(SD,'SrcPos')
246+
obj.CopyProbe(SD);
243247
if isempty(obj.SD) && err == 0
244248
err = -4;
245249
end
@@ -361,10 +365,15 @@ function SaveMat(obj, fname, options)
361365
end
362366
[~, k1] = sortrows(obj.SD.MeasList);
363367
[~, k2] = sortrows(obj2.SD.MeasList);
364-
if ~all(obj.SD.MeasList(k1,:) == obj2.SD.MeasList(k2,:))
368+
369+
% Compare meas list dimensions first - if that's not equal then the probes aren't equal
370+
if ~all( size(obj.SD.MeasList(k1,:)) == size(obj2.SD.MeasList(k2,:)) )
365371
return;
366-
end
372+
end
367373

374+
if ~all(obj.SD.MeasList(k1,:) == obj2.SD.MeasList(k2,:))
375+
return;
376+
end
368377

369378
for kk = 1:length(fields)
370379
for jj = 1:length(fields{kk})
@@ -1261,7 +1270,7 @@ function FixProbeSpatialUnit(obj)
12611270

12621271

12631272
% ----------------------------------------------------------------------------------
1264-
function CopyProbe(obj, SD) %#ok<INUSD>
1273+
function CopyProbe(obj, SD)
12651274
fields = propnames(obj.SD);
12661275
for ii = 1:length(fields)
12671276
if eval( sprintf('isfield(SD, ''%s'')', fields{ii}) )
@@ -1339,7 +1348,7 @@ function CopyProbe(obj, SD) %#ok<INUSD>
13391348

13401349
% MesListAct
13411350
if size(obj.SD.MeasListAct,1) < size(obj.SD.MeasList,1)
1342-
d = size(obj.SD.MeasListAct,1) - size(obj.SD.MeasList,1);
1351+
d = size(obj.SD.MeasListAct,1) - size(obj.SD.MeasList,1); %#ok<*PROPLC>
13431352
if d < 0
13441353
obj.SD.MeasListAct(end+1:end+abs(d)) = ones(abs(d),1);
13451354
elseif d>1
@@ -1376,8 +1385,68 @@ function CopyStruct(obj, s)
13761385
end
13771386
end
13781387
end
1388+
1389+
1390+
1391+
% ----------------------------------------------------------------------------------
1392+
function b = IsProbeFlat(obj)
1393+
b = false;
1394+
if length(obj.SD.SrcPos) == length(obj.SD.SrcPos3D)
1395+
if ~all(obj.SD.SrcPos == obj.SD.SrcPos3D)
1396+
return;
1397+
end
1398+
end
1399+
if length(obj.SD.DetPos) == length(obj.SD.DetPos3D)
1400+
if ~all(obj.SD.DetPos == obj.SD.DetPos3D)
1401+
return
1402+
end
1403+
end
1404+
optpos = [obj.SD.SrcPos3D; obj.SD.DetPos3D];
1405+
ncoord = size(optpos, 2);
1406+
for ii = 1:ncoord
1407+
if length(unique(optpos(:,ii)))==1
1408+
b = true;
1409+
return
1410+
end
1411+
end
1412+
b = true;
1413+
end
1414+
1415+
1416+
1417+
% ----------------------------------------------------------------------------------
1418+
function b = Are3DLandmarksFlat(obj)
1419+
b = true;
1420+
if isempty(obj.SD.Landmarks3D.pos)
1421+
return;
1422+
end
1423+
ncoord = size(obj.SD.Landmarks3D.pos, 2);
1424+
for ii = 1:ncoord
1425+
if length(unique(obj.SD.Landmarks3D.pos(:,ii)))==1
1426+
return;
1427+
end
1428+
end
1429+
b = false;
1430+
end
1431+
13791432

13801433

1434+
% ----------------------------------------------------------------------------------
1435+
function b = AreLandmarksFlat(obj)
1436+
b = true;
1437+
if isempty(obj.SD.Landmarks.pos)
1438+
return;
1439+
end
1440+
ncoord = size(obj.SD.Landmarks.pos, 2);
1441+
for ii = 1:ncoord
1442+
if length(unique(obj.SD.Landmarks.pos(:,ii)))==1
1443+
return;
1444+
end
1445+
end
1446+
b = false;
1447+
end
1448+
1449+
13811450

13821451
% ----------------------------------------------------------------------------------
13831452
function err = ConvertSnirfProbe(obj, snirf)
@@ -1391,7 +1460,7 @@ function CopyStruct(obj, s)
13911460
try
13921461
obj.SD.Lambda = snirf.probe.wavelengths;
13931462
obj.SD.SrcPos = snirf.probe.sourcePos2D;
1394-
obj.SD.DetPos = snirf.probe.detectorPos2D;
1463+
obj.SD.DetPos = snirf.probe.detectorPos2D;
13951464
obj.SD.SrcPos3D = snirf.probe.sourcePos3D;
13961465
obj.SD.DetPos3D = snirf.probe.detectorPos3D;
13971466
obj.SD.MeasList = snirf.GetMeasList();
@@ -1400,17 +1469,17 @@ function CopyStruct(obj, s)
14001469
obj.SD.Landmarks3D.labels = snirf.probe.landmarkLabels;
14011470
obj.SD.Landmarks3D.pos = snirf.probe.landmarkPos3D;
14021471
end
1403-
if length(snirf.probe.landmarkLabels) == size(snirf.probe.landmarkPos2D,1)
1404-
obj.SD.Landmarks2D.labels = snirf.probe.landmarkLabels;
1405-
obj.SD.Landmarks2D.pos = snirf.probe.landmarkPos2D;
1406-
end
1407-
if ~isempty(obj.SD.Landmarks3D.labels)
1408-
obj.SD.Landmarks.pos = obj.SD.Landmarks3D.pos;
1409-
obj.SD.Landmarks.labels = obj.SD.Landmarks3D.labels;
1410-
elseif ~isempty(obj.SD.Landmarks2D.labels)
1411-
obj.SD.Landmarks.pos = obj.SD.Landmarks2D.pos;
1412-
obj.SD.Landmarks.labels = obj.SD.Landmarks2D.labels;
1413-
end
1472+
if length(snirf.probe.landmarkLabels) == size(snirf.probe.landmarkPos2D,1)
1473+
obj.SD.Landmarks2D.labels = snirf.probe.landmarkLabels;
1474+
obj.SD.Landmarks2D.pos = snirf.probe.landmarkPos2D;
1475+
end
1476+
if ~isempty(obj.SD.Landmarks3D.labels)
1477+
obj.SD.Landmarks.pos = obj.SD.Landmarks3D.pos;
1478+
obj.SD.Landmarks.labels = obj.SD.Landmarks3D.labels;
1479+
elseif ~isempty(obj.SD.Landmarks2D.labels)
1480+
obj.SD.Landmarks.pos = obj.SD.Landmarks2D.pos;
1481+
obj.SD.Landmarks.labels = obj.SD.Landmarks2D.labels;
1482+
end
14141483
catch
14151484
err = -1;
14161485
end
@@ -1452,10 +1521,7 @@ function ConvertSnirfStim(obj, snirf)
14521521

14531522
% ----------------------------------------------------------------------------------
14541523
function ConvertSnirfAux(obj, snirf)
1455-
obj.aux = zeros(length(obj.t), length(snirf.aux));
1456-
for ii = 1:length(snirf.aux)
1457-
obj.aux(:,ii) = snirf.aux(ii).dataTimeSeries;
1458-
end
1524+
obj.aux = snirf.GetAuxDataMatrix();
14591525
end
14601526

14611527

@@ -1541,7 +1607,14 @@ function ErrorCheck(obj)
15411607
end
15421608
end
15431609
end
1544-
1610+
if obj.IsProbeFlat()
1611+
obj.SD.SrcPos3D = [];
1612+
obj.SD.DetPos3D = [];
1613+
end
1614+
if obj.Are3DLandmarksFlat() && ~obj.AreLandmarksFlat()
1615+
obj.SD.Landmarks3D.pos = obj.SD.Landmarks.pos;
1616+
obj.SD.Landmarks3D.labels = obj.SD.Landmarks.labels;
1617+
end
15451618
end
15461619

15471620

DataTree/AcquiredData/Snirf/AuxClass.m

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,14 @@ function SetDataTimeSeries(obj, val)
179179
% ----------------------------------------------------------------------------------
180180
function Copy(obj, obj2)
181181
if isempty(obj)
182-
obj = DataClass();
182+
obj = AuxClass();
183183
end
184-
if ~isa(obj2, 'DataClass')
184+
if ~isa(obj2, 'AuxClass')
185185
return;
186186
end
187-
for ii=1:length(obj2.measurementList)
188-
obj.measurementList(ii) = obj2.measurementList(ii).copy(); % shallow copy ok because MeasListClass has no handle properties
189-
end
190-
obj.dataTimeSeries = obj2.dataTimeSeries;
191-
obj.time = obj2.time;
187+
obj.dataTimeSeries = obj2.dataTimeSeries;
188+
obj.time = obj2.time;
189+
obj.timeOffset = obj2.timeOffset;
192190
end
193191

194192

DataTree/Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.15.4
1+
1.16.1

Utils/Shared/ConfigFileClass.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,9 @@ function FindCfgFiles(obj, rootdir)
661661
if strcmp(dirs(ii).name, 'submodules')
662662
continue;
663663
end
664+
if strcmp(dirs(ii).name, 'Install')
665+
continue;
666+
end
664667
obj.FindCfgFiles([rootdir, dirs(ii).name]);
665668
end
666669
end

Utils/Shared/Version.txt

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

Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.80.6
1+
1.80.7

0 commit comments

Comments
 (0)