vistalab / vistasoft

VISTASOFT is the main software repository of the VISTA lab at Stanford University.
http://vistalab.stanford.edu
148 stars 142 forks source link

pRF issue with rmSave and Inplane ROIs #118

Closed ariekahn closed 9 years ago

ariekahn commented 10 years ago

When I try to run a pRF analysis on an ROI defined in an inplane view, I run into the following issue at the end of the grid fit.

[rmMakeTrends]: Removing 1 trends from combined data.
[rmGridFit]:Number of voxels: 8330.
[rmGridFit_oneGaussian]:Estimated processing time: 7 minutes.   (21-Oct-2014 10:25:12)
[rmGridFit_oneGaussian]:Grid (x,y,sigma) fit:..........Done[7 minutes]. (21-Oct-2014 10:30:39)
Parameter size error.
x
Error using reshape
To RESHAPE the number of elements must not change.

Error in rmSave>myreshape (line 170)
    mapdata = reshape(param.',dims);

Error in rmSave (line 65)
                                param = myreshape(param,dims,coordsInd);

Error in rmGridFit (line 318)
rmFile = rmSave(view,model,params,1,'gFit');

Error in rmMain (line 126)
        view = rmGridFit(view,params);

The code in question is:

function mapdata = myreshape(param,dims,coordsInd)

if isequal(dims, size(param))

    mapdata = param;
    return
end

if ~isequal(length(coordsInd), prod(dims))
    % otherwise
    mapdata = reshape(param.',dims);
else
    mapdata = zeros(dims);
    mapdata(coordsInd) = param;
end;
return;

In this particular case, it seems like we'd want to map the ROI voxels back using coordsInd, as in the third branch there, but as the ROI is smaller than the voxel dimension, we're executing the second (and I'm not sure entirely what its use case is) and crashing.

JWinawer commented 10 years ago

Hi Arie,

I don't recall whether the pRF implementation ever worked cleanly for Inplane data. At one point I tried running models in the Inplane view and ran into code problems and gave up. The problem, as I recall, has to do with how the voxels are indexed in the data fields of the model solutions. For the gray view, the voxels are indexed implicitly as a single number, from 1 to n where n is the number of voxels. So, for example, if there are 100,000 voxels and 1 x value per voxel, then x is stored as a 1 x 100,000 array. For the beta weights, if there are 8 weights per voxel, then beta is stored as 1 x 100,000 x 8 array. I believe that for models of slice data, the model solutiuons are stored in the shape of the slap. So for a 64 x 64 x 20 data set, x would be stored as 64 x 64 x 20, and beta would be stored as 64 x 64 x 20 x 6 (if there are 6 beta weights). This got confusing and caused problems. The better solution would be to flatten the inplane data into a vector and store the results in the same way as they are stored for the Gray view.

My recollection is that currently, the code fails for inplane models, and someone would have ti actually implement the storage in a consistent manner.

Jon

On Tue, Oct 21, 2014 at 10:46 AM, ariekahn notifications@github.com wrote:

When I try to run a pRF analysis on an ROI defined in an inplane view, I run into the following issue at the end of the grid fit.

[rmMakeTrends]: Removing 1 trends from combined data. [rmGridFit]:Number of voxels: 8330. rmGridFit_oneGaussian:Estimated processing time: 7 minutes. (21-Oct-2014 10:25:12)

Parameter size error. x Error using reshape To RESHAPE the number of elements must not change.

Error in rmSave>myreshape (line 170) mapdata = reshape(param.',dims);

Error in rmSave (line 65) param = myreshape(param,dims,coordsInd);

Error in rmGridFit (line 318) rmFile = rmSave(view,model,params,1,'gFit');

Error in rmMain (line 126) view = rmGridFit(view,params);

The code in question is:

function mapdata = myreshape(param,dims,coordsInd)

if isequal(dims, size(param))

mapdata = param;
return

end

if ~isequal(length(coordsInd), prod(dims)) % otherwise mapdata = reshape(param.',dims); else mapdata = zeros(dims); mapdata(coordsInd) = param; end; return;

In this particular case, it seems like we'd want to map the ROI voxels back using coordsInd, as in the third branch there, but as the ROI is smaller than the voxel dimension, we're executing the second (and I'm not sure entirely what its use case is) and crashing.

— Reply to this email directly or view it on GitHub https://github.com/vistalab/vistasoft/issues/118.

Jonathan Winawer Assistant Professor of Psychology and Neural Science

New York University 6 Washington Place New York, NY, 10003 (212) 998-7922 (phone) (212) 995-4018 (fax) jonathan.winawer@nyu.edu http://psych.nyu.edu/winawer/