From 2ef41b8c46e52de9643553c5bc5450ba8fddb093 Mon Sep 17 00:00:00 2001 From: Akshay Jagadeesh Date: Thu, 5 Sep 2019 04:17:29 -0700 Subject: [PATCH] Adding feature to save ROI prf params when you add roi to anatdb --- mrLoadRet/PluginAlt/mlrAnatDB/mlrAnatDBPut.m | 20 ++++++++++++++++++++ mrLoadRet/View/isroi.m | 4 +++- mrLoadRet/View/viewSet.m | 20 +++++++++++++++++--- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/mrLoadRet/PluginAlt/mlrAnatDB/mlrAnatDBPut.m b/mrLoadRet/PluginAlt/mlrAnatDB/mlrAnatDBPut.m index ff802e3a5..80adca43e 100644 --- a/mrLoadRet/PluginAlt/mlrAnatDB/mlrAnatDBPut.m +++ b/mrLoadRet/PluginAlt/mlrAnatDB/mlrAnatDBPut.m @@ -685,6 +685,26 @@ % set that the ROI is created from this session v = viewSet(v,'roiBranchNum',branchNum+1,iRoi); end + % Add the pRF Params if they exist + if ~isfield(roi, 'pRFparams') || isempty(roi.pRFparams) + % Check if there is a pRF analysis loaded + analysis = viewGet(v, 'analysis'); + if ~isempty(analysis) && strcmp(analysis.type, 'pRFAnal') + % if so, extract the pRF params for this roi + d = viewGet(v, 'd'); + [scanCoords scan2roi] = getROICoordinates(v,iRoi); + linScanCoords = sub2ind(viewGet(v, 'scanDims'), scanCoords(1,:), scanCoords(2,:), scanCoords(3,:)); + [~,idx] = ismember(linScanCoords, d.linearCoords); % + idx = idx(idx~=0); + roipRFparams = [d.params(:, idx); d.r(idx)']; % 4 x nVoxels + + % and call viewSet to set the "roipRFparams" field of the roi + val = {}; val{1} = roipRFparams; + val{2} = viewGet(v, 'scan2roi'); + v = viewSet(v, 'roipRFparams', val, iRoi); + end + end + % save it filePath{end+1} = saveROI(v,iRoi,false); % set the .mat extension diff --git a/mrLoadRet/View/isroi.m b/mrLoadRet/View/isroi.m index aaf38878d..c8cab1561 100644 --- a/mrLoadRet/View/isroi.m +++ b/mrLoadRet/View/isroi.m @@ -34,11 +34,13 @@ 'createdFromSession',''; 'branchNum',[]; 'subjectID',[]; + 'pRFparams', []; + 'scan2roi', []; }; else % Return 0 if the overlay structure is missing any fields required or % optional (since w/out changing the analysis structure it is invalid). - requiredFields = {'color','coords','date','name','viewType','voxelSize','xform','sformCode','vol2mag','vol2tal','createdBy','createdOnBase','displayOnBase','createdFromSession','branchNum','subjectID'}; + requiredFields = {'color','coords','date','name','viewType','voxelSize','xform','sformCode','vol2mag','vol2tal','createdBy','createdOnBase','displayOnBase','createdFromSession','branchNum','subjectID', 'pRFparams', 'scan2roi'}; optionalFields = {}; end diff --git a/mrLoadRet/View/viewSet.m b/mrLoadRet/View/viewSet.m index ff8a3c64b..26b47eb0c 100644 --- a/mrLoadRet/View/viewSet.m +++ b/mrLoadRet/View/viewSet.m @@ -23,7 +23,7 @@ % view = viewSet(view,'basemin',number,[baseNum]); % view = viewSet(view,'basemax',number,[baseNum]); % -% view = viewSet(view,'newanalysis',analysisStructure); +% view = viewSet(view,'newanalysis',analysisStructure); % view = viewSet(view,'deleteAnalysis',analysisNum); % view = viewSet(view,'currentAnalysis',analysisNum); % @@ -2243,7 +2243,21 @@ if ~isempty(roiNum) view.ROIs(roiNum).createdOnBase = val; end - + + case {'roiprfparams'} + % v = viewSet(v,'roiCreatedOnBase',baseName,[roiNum]); + % sets the created on base field of roi + curRoi = viewGet(view,'currentRoi'); + if ~isempty(varargin) + roiNum = varargin{1}; + else + roiNum = curRoi; + end + if ~isempty(roiNum) + view.ROIs(roiNum).pRFparams = val{1}; % x y + view.ROIs(roiNum).scan2roi = val{2}; + end + case {'roicreatedfromsession'} % v = viewSet(v,'roiCreatedFromSession',sessionName,[roiNum]); % sets the created from session field in roi @@ -2493,7 +2507,7 @@ MLR.callbacks{2}{end+1} = {varargin{1}}; end end - + otherwise mrWarnDlg(sprintf('(viewSet) Unknown parameter %s',param)); end