Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding feature to save ROI prf params when you add roi to anatdb #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions mrLoadRet/PluginAlt/mlrAnatDB/mlrAnatDBPut.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion mrLoadRet/View/isroi.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 17 additions & 3 deletions mrLoadRet/View/viewSet.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
%
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2493,7 +2507,7 @@
MLR.callbacks{2}{end+1} = {varargin{1}};
end
end

otherwise
mrWarnDlg(sprintf('(viewSet) Unknown parameter %s',param));
end
Expand Down