Skip to content

Commit

Permalink
v2.42.0
Browse files Browse the repository at this point in the history
-- Make condition names loading work. Display actual condition names in GUI, change condition edit boxes to condition popupmenu types. Do image recon based on the displayed condition. Pass currently selected condition to ImageRecon gui.
-- Fix another bug in image recon display where the cortex display turns all red when switching between sensitivity and Hb Conc image recon displays. Add function turnOffAllOtherPatches in setImageDisplay_EmptyImage.m to turn off visibility for all patches other than the one being displayed

* DataTree, v1.14.2
-- Fix events TSV file naming bug. Add TSV file name method TreeNode.GetStimTsvFilename() to use for all events TSV file naming. Add config param "Replace TSV File Tabs with Spaces" to handle events TSV errors when file  is a mix of spaces and tabs.
-- Fixes to setpaths for running DataTree standalone

* Utils, v1.6.0
-- Fix some bugs in events TSV stim loading error handling. Add config param "Replace TSV File Tabs with Spaces" to handle events TSV errors when file  is a mix of spaces and tabs.
-- Add method ConfigFileClass.GetValueOptions for getting all available value options for a param.
  • Loading branch information
jayd1860 committed May 12, 2023
1 parent 9b8f70e commit e7ac646
Show file tree
Hide file tree
Showing 19 changed files with 794 additions and 179 deletions.
Binary file modified AtlasViewerGUI.fig
Binary file not shown.
58 changes: 7 additions & 51 deletions AtlasViewerGUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -2712,7 +2712,7 @@ function menuItemSetMCParams_Callback(~, ~, ~)


% --------------------------------------------------------------------
function pushbuttonCalcMetrics_new_Callback(hObject, eventdata, handles)
function pushbuttonCalcMetrics_new_Callback(~, ~, handles)
global atlasViewer

imgrecon = atlasViewer.imgrecon;
Expand Down Expand Up @@ -2740,9 +2740,9 @@ function pushbuttonCalcMetrics_new_Callback(hObject, eventdata, handles)


% --------------------------------------------------------------------
function menuItemImageReconGUI_Callback(hObject, eventdata, handles)
global atlasViewer
ImageRecon();
function menuItemImageReconGUI_Callback(~, ~, handles)
iCond = get(handles.editCondition,'value');
ImageRecon(iCond);



Expand Down Expand Up @@ -2809,53 +2809,9 @@ function menuItemOverlayHbConc_Callback(~, ~, ~)


% --------------------------------------------------------------------
function editCondition_Callback(hObject, ~, handles)
global atlasViewer

hbconc = atlasViewer.hbconc;
imgrecon = atlasViewer.imgrecon;
fwmodel = atlasViewer.fwmodel;
pialsurf = atlasViewer.pialsurf;
probe = atlasViewer.probe;

condstr = get(hObject, 'string');
if isempty(condstr)
set(hObject, 'string', num2str(hbconc.iCond));
return;
end
if ~isnumber(condstr)
set(hObject, 'string', num2str(hbconc.iCond));
return;
end
cond = str2num(condstr);
if floor(str2num(condstr))~=cond
set(hObject, 'string', num2str(hbconc.iCond));
return;
end
if (cond < 1) | (cond > size(hbconc.HbConcRaw,4))
set(hObject, 'string', num2str(hbconc.iCond));
return;
end
if hbconc.iCond == cond
return;
end
val = get(handles.popupmenuImageDisplay,'value');
if val ~= hbconc.menuoffset+1 & val ~= hbconc.menuoffset+2
return;
end

hbconc = calcHbConc(hbconc, probe);
hbconc = calcHbConcCmThreshold(hbconc);
set(hbconc.handles.editColormapThreshold, ...
'string',sprintf('%0.2g %0.2g', hbconc.cmThreshold(1,1), hbconc.cmThreshold(1,2)));

% Turn off the other object displays that share the Image Display panel
fwmodel = showFwmodelDisplay(fwmodel, [], 'off');
imgrecon = showImgReconDisplay(imgrecon, [], 'off','off','off','off');

hbconc = displayHbConc(hbconc, pialsurf, probe, fwmodel, imgrecon);

atlasViewer.hbconc = hbconc;
function editCondition_Callback(hObject, ~, ~)
iCond = get(hObject, 'value');
ImageRecon(iCond);



Expand Down
9 changes: 7 additions & 2 deletions AtlasViewerGUI_enableDisable.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ function AtlasViewerGUI_enableDisable(handles)
end


if isempty(digpts.refpts.pos) | isempty(refpts.pos) | isempty(headsurf.mesh.vertices)
if isempty(digpts.refpts.pos) || isempty(refpts.pos) || isempty(headsurf.mesh.vertices)
set(handles.menuItemRegisterAtlasToDigpts,'enable','off')
else
set(handles.menuItemRegisterAtlasToDigpts,'enable','on')
end

% Set the GUI controls for post-probe-registration controls,
% like fw model, image recon, hb overlay,
fwmodel = updateGuiControls_AfterProbeRegistration(probe, fwmodel, imgrecon, labelssurf);
updateGuiControls_AfterProbeRegistration(probe, fwmodel, imgrecon, labelssurf);

if ~isempty(atlasViewer.dataTree)
set(handles.editCondition, 'string',atlasViewer.dataTree.currElem.CondNames, 'value',1,'enable','on');
else
set(handles.editCondition, 'enable','off');
end

7 changes: 0 additions & 7 deletions Group/DataTree/AcquiredData/DataFiles/SnirfFile2Tsv.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,4 @@
writeTsv(dst, tsv);
end

% Remove stim from
% if optionExists(options, 'removeStim')
% s.Load();
% s.stim = StimClass().empty();
% s.Save();
% end


3 changes: 3 additions & 0 deletions Group/DataTree/AppSettings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ No
% Quiet Mode # On, Off
Off

% Replace TSV File Tabs with Spaces # auto-replace, ask me, don't replace and don't ask me
ask me

% END
14 changes: 12 additions & 2 deletions Group/DataTree/TreeNodeClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,17 @@ function ReloadStim(obj)



% ----------------------------------------------------------------------------------
function fnameTsv = GetStimTsvFilename(obj)
fnameTsv = [];
if isempty(obj.acquired)
return;
end
fnameTsv = obj.acquired.GetStimTsvFilename();
end



% ----------------------------------------------------------------------------------
function EditStim(obj, waitForInput)
if ~exist('waitForInput','var')
Expand All @@ -558,10 +569,9 @@ function EditStim(obj, waitForInput)
return;
end
filenameData = [obj.path, obj.GetFilename()];
[p1,f1] = fileparts(filenameData);

% From data file name get events TSV file and load in matlab editor
filenameEvents = [p1, '/', f1, '_events.tsv'];
filenameEvents = obj.GetStimTsvFilename();
if ~ispathvalid(filenameEvents)
obj.logger.Write('Events TSV file for %s doesn''t exist.\n', filenameData);
obj.ExportStim();
Expand Down
2 changes: 1 addition & 1 deletion Group/DataTree/Version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.14.1
1.14.2
107 changes: 77 additions & 30 deletions Group/DataTree/setpaths.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ function setpaths(addremove)
% Add libraries on which DataTreeClass depends
d = addDependenciesSearchPaths();

if ~isempty(which('setNamespace.m'))
setNamespace(appname);
end

% Start logger only after adding library paths. Logger is in the Utils libary.
logger = Logger('setpaths');

Expand Down Expand Up @@ -127,15 +131,14 @@ function setpaths(addremove)

warning('on','MATLAB:rmpath:DirNotFound');

PrintSystemInfo(logger, ['DataTreeClass'; d]);
PrintSystemInfo(logger, [appname; d]);
logger.CurrTime('Setpaths completed on ');
logger.Close();
cd(currdir);

catch ME

printStack(ME)
if exist('logger','var')
if exist('logger','var') && isa(logger, 'Logger')
logger.Close();
end
cd(currdir);
Expand Down Expand Up @@ -180,7 +183,7 @@ function addSearchPaths(appPaths)
else
delimiter = ':';
end
appPaths = str2cell(p, delimiter);
appPaths = str2cell_startup(p, delimiter);
end
for kk = 1:length(appPaths)
if strfind(appPaths{kk}, '.git')
Expand Down Expand Up @@ -225,28 +228,23 @@ function removeSearchPaths(app)

% ----------------------------------------------------
function d = addDependenciesSearchPaths()
if exist([pwd, '/Utils/submodules'],'dir')
addpath([pwd, '/Utils/submodules'],'-end');
end
d = dependencies();
for ii = 1:length(d)
rootpath = findFolder(pwd, d{ii});
rootpath(rootpath=='\') = '/';
if ispathvalid_startup([rootpath, '/Shared'],'dir')
rootpath = [rootpath, '/Shared'];
end
if ~exist(rootpath,'dir')
submodules = downloadDependencies();
d = cell(size(submodules,1),1);
for ii = 1:size(submodules)
submodulespath = [filesepStandard_startup(pwd), submodules{ii,end}];
if ~exist(submodulespath,'dir')
printMethod(sprintf('ERROR: Could not find required dependency %s\n', d{ii}));
continue;
end
addSearchPaths(rootpath);
printMethod(sprintf('Adding searchpaths for submodule %s\n', submodulespath));
addSearchPaths(submodulespath);
d{ii,1} = submodules{ii,end};
end




% -----------------------------------------------------------------------------
function [C,k] = str2cell(str, delimiters, options)
function [C,k] = str2cell_startup(str, delimiters, options)

% Option tells weather to keep leading whitespaces.
% (Trailing whitespaces are always removed)
Expand Down Expand Up @@ -310,6 +308,55 @@ function printMethod(msg)



% -------------------------------------------------------------------------
function submodules = parseGitSubmodulesFile(repo)
submodules = cell(0,3);

if ~exist('repo','var') || isempty(repo)
repo = pwd;
end
currdir = pwd;
if repo(end) ~= '/' && repo(end) ~= '\'
repo = [repo, '/'];
end

filename = [repo, '.gitmodules'];
if ~exist(filename, 'file')
return;
end
cd(repo);

fid = fopen(filename, 'rt');
strs = textscan(fid, '%s');
strs = strs{1};
kk = 1;
for ii = 1:length(strs)
if strcmp(strs{ii}, '[submodule')
jj = 1;
while ~strcmp(strs{ii+jj}, '[submodule')
if ii+jj+2>length(strs)
break;
end
if strcmp(strs{ii+jj}, 'path')
submodules{kk,2} = [pwd, '/', strs{ii+jj+2}];
end
if strcmp(strs{ii+jj}, 'path')
submodules{kk,3} = strs{ii+jj+2};
end
if strcmp(strs{ii+jj}, 'url')
submodules{kk,1} = strs{ii+jj+2};
end
jj = jj+1;
end
kk = kk+1;
end
end
fclose(fid);
cd(currdir);




% -------------------------------------------------------------------------
function dirpath = findFolder(repo, dirname)
dirpath = '';
Expand Down Expand Up @@ -351,9 +398,9 @@ function printMethod(msg)
exclList = {exclList};
end

subdirFullpath = filesepStandard(subdir,'full');
subdirFullpath = filesepStandard_startup(subdir,'full');

if ~ispathvalid(subdirFullpath, 'dir')
if ~ispathvalid_startup(subdirFullpath, 'dir')
logger.Write('Warning: folder %s doesn''t exist\n', subdirFullpath);
return;
end
Expand All @@ -369,7 +416,7 @@ function printMethod(msg)
end

if isdotmfolder(subdirFullpath)
dotmfolders = {filesepStandard(subdirFullpath, 'nameonly')};
dotmfolders = {filesepStandard_startup(subdirFullpath, 'nameonly')};
end

for ii = 1:length(dirs)
Expand All @@ -390,7 +437,7 @@ function printMethod(msg)
function b = isdotmfolder(folder)
global MAXPATHLENGTH
b = false;
if ~ispathvalid(folder, 'dir')
if ~ispathvalid_startup(folder, 'dir')
return
end
if isempty(dir([folder,'/*.m']))
Expand Down Expand Up @@ -421,7 +468,7 @@ function printMethod(msg)
if pname(end)=='/'
pname(end) = '';
end
if ~ispathvalid(pname,'dir')
if ~ispathvalid_startup(pname,'dir')
return;
end
[~,f,e] = fileparts(pname);
Expand Down Expand Up @@ -452,13 +499,13 @@ function printMethod(msg)
if ~exist('options','var')
options = '';
end
if optionExists(options, 'nochange')
if optionExists_startup(options, 'nochange')
option = '';
else
option = 'full';
end
p1 = filesepStandard(p1_0, option);
p2 = filesepStandard(p2_0, option);
p1 = filesepStandard_startup(p1_0, option);
p2 = filesepStandard_startup(p2_0, option);
if isempty(p1)
p1 = p1_0;
end
Expand All @@ -481,7 +528,7 @@ function printMethod(msg)

%
% Usage:
% pathname = filesepStandard(pathname, options)
% pathname = filesepStandard_startup(pathname, options)
%
% Takes a pathname as argument and replaces any non-standard file/folder
% separators with standard ones, that is '/'. It also gets rid of redundant
Expand All @@ -490,7 +537,7 @@ function printMethod(msg)
% Example:
%
% >> pathname = 'C:\dir1\\\dir2\\dir3\test1/\test2/'
% >> pathname = filesepStandard(pathname)
% >> pathname = filesepStandard_startup(pathname)
%
% pathname =
%
Expand Down Expand Up @@ -754,8 +801,8 @@ function printMethod(msg)
path1 = lower(path1);
path2 = lower(path2);
end
p1 = str2cell(path1,{'\','/'});
p2 = str2cell(path2,{'\','/'});
p1 = str2cell_startup(path1,{'\','/'});
p2 = str2cell_startup(path2,{'\','/'});
if length(p1) ~= length(p2)
return;
end
Expand Down
3 changes: 1 addition & 2 deletions HbConc/calcHbConc.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
end

% Get condition
str = get(hbconc.handles.editCondition, 'string');
hbconc.iCond = str2num(str);
hbconc.iCond = get(hbconc.handles.editCondition, 'value');
iCond = hbconc.iCond;
if iCond<1 | iCond>size(hbconc.HbConcRaw,4)
hbconc.HbO = [];
Expand Down
Binary file modified ImgRecon/ImageRecon.fig
Binary file not shown.
Loading

0 comments on commit e7ac646

Please sign in to comment.