Code Monkey home page Code Monkey logo

mrtools's Introduction

mrTools Overview

mrTools provides a set of Matlab tools to analyze fMRI data. It can do basic analyses like correlation analyses used in retinotopy experiments, event-related, population RF and GLM analyses. It can display the results of analyses on inplane anatomies, flat maps and surfaces. It is designed to make it easy to write your own script and programs in Matlab to analyze your data.

mrTools Documentation

Full documentation can be found here: https://gru.stanford.edu/doku.php/mrtools/overview

mrTools Citation

Gardner, Justin L., Merriam, Elisha P., Schluppeck, Denis, Besle, Julien, & Heeger, David J. (2018, June 28). mrTools: Analysis and visualization package for functional magnetic resonance imaging data (Version 4.7). Zenodo. http://doi.org/10.5281/zenodo.1299483

DOI

Screen shots

Event-related analysis

Event-related analysis

Surfaces and flat-maps

Surface and flat-maps

Retinotopy

Retinotopy

Correlation analysis

Correlation analysis

Population receptive-fields

Population receptive-field

mrtools's People

Contributors

justingardner avatar julienbesle avatar dbirman avatar schluppeck avatar steevelaquitaine avatar austinchkuo avatar bengurer avatar mlee17 avatar

Stargazers

 avatar Peter J. Kohler avatar  avatar Ali Aghaeifar avatar HuoTengbin avatar Username avatar Zoey Isherwood avatar Rui Antunes avatar Francisco Maria Calisto avatar Benoît Béranger avatar  avatar Andreas avatar Cecil Yen avatar Eric avatar Christopher Madan avatar Kevin M Aquino avatar  avatar

Watchers

James Cloos avatar Franco Pestilli avatar Akshay Jagadeesh avatar Eric avatar Christopher Madan avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar Andreas avatar

mrtools's Issues

Using mrInterrogator functions (like EventRelatedPlot, etc) when clicking within an ROI

When clicking within an ROI in the GUI, the EventRelatedPlot function and other interrogators do not work. Previously, displayed single-voxel results of deconvolution analysis and recalculated analysis on mean time series in ROI. Clicking outside the ROI works fine, displays single-voxel results. When ROI is hidden, single-voxel results display. Possible issue: MATLAB rendering ROI in front of surface, so click on surface is not registering?

Matlab Version: 8.5.0.197613 (R2015A)
O/S: Yosemite 10.10.5
Branch: -notts-newfeatures

Put together a set of data

Needs retinotopy, surfaces from freeSurfer (converted to mrTools using mlrFreeSurfer whatever it is called) a T1 anatomy and dt6 images and fascicles

(Future Compatibility Issue):

The fullcrosshair mouse pointer is deprecated in R2014b. Trying to use it causes a warning and then sets the pointer to crosshair. atmo, this only occurs in 3 files in the mrTools code:

mrSearchHelp('fullcrosshair')
---------------------------------------------------------------------------
talairach.m:102:     set(gTalairach.fig(a(1)),'pointer','fullcrosshair');
talairach.m:407: set(gTalairach.fig(1),'pointer','fullcrosshair');
talairach.m:408: set(gTalairach.fig(2),'pointer','fullcrosshair');
talairach.m:409: set(gTalairach.fig(3),'pointer','fullcrosshair');
mrInterrogator.m:133:   set(MLR.interrogator{viewNum}.fignum,'pointer','fullcrosshair');
mlrVol.m:131:   set(gcf,'Pointer','fullcrosshair');
---------------------------------------------------------------------------

Using crosshair instead fixes this (but at the cost of not having the nice cross hairs).

Add viewSet for roiChange

This will act like baseChange callback which will be used by Franco to update the listbox with what ROI names are loaded.

roi2base caching

Make the rois cache there base conversions so they don't have to be computed each time the user clicks.

Convert Cortical Depth Deletes ROIs

Error can be consistently re-created in s031020150815 in mlrAnatDB. Generate rV1 and rV2v ROIs on s0310_right_occipital_r90 flat, select a different base anatomy (e.g. (s0310_left_occipital_r90), convert cortical depth, crashes with error:

Improper assignment with rectangular empty matrix.

Error in convertROICorticalDepth (line 133)
        [roiBaseCoords(1,:) roiBaseCoords(2,:) roiBaseCoords(3,:)] =
        ind2sub(baseDims,roiBaseCoordsLinear);

And the ROI will be gone.

I can re-create the error consistently by being on any base other than the base that the ROIs I am trying to convert are on. (e.g. if my ROI is on left_occipital and I am on base right_occipital, it will delete my ROI when I convert any ROIs drawn on the left base).

(This error was previously reported by Joujou, but I don't think he knew why it was occurring, so it occurs on at least two machines).

No stimefile matching when mrInit is called from dofmricni

(mrInit) Unknown argument stimfileMatchList

Stimfiles aren't being matched correctly, it just picks them in order by number. Not sure if this is isolated to when you specify your own stimfileMatchList or in the default case as well.. I'm still investigating.

Add menu items for planar ROIS

This gets set from mlrLifePlugin - should add ROI create items that allow you to make for example an ROI plane in the axial dimension or whatever.

R2019a weirdness with plugins

... just came across this (and thought I was slowly losing the plot).

I think mlrAdjustGUI can't do some of the GUI adjustments in more recent versions (I tried to R2019a). Not quite sure which bit of TMW 💯 genius addition has broken this... but leads to GLM_v2 plugin not being loadable.

Just keep an eye out - possibly similar issues with other site-specific plugins people are using.

I will try to have another look at this soon - in the meantime some details on what this looks like for me (R2019a, macos 10.13.6, high sierra)

>> mrLoadRet
(mrGlobals) mrTools has been tested on Matlab versions 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 7.1 7.11 7.12 7.13 7.14 8.0 8.1 8.2. You are running Matlab 9.6
(mrGlobals) mrLoadRet 4.7, Matlab 9.6
(mlrPlugin) Installing plugin Default
(mlrPlugin) Installing plugin GLM_v2
(mlrAdjustGUI) *** Could not find property callback of uimenu exportImageMenuItem ***
(mlrAdjustGUI) *** Could not find property label of uimenu exportImageMenuItem ***
(mlrAdjustGUI) *** Could not find property callback of uimenu copyOverlayMenuItem ***
(mlrAdjustGUI) *** Could not find property label of uimenu copyOverlayMenuItem ***
(mlrAdjustGUI) *** Could not find property callback of uimenu pasteOverlayMenuItem ***
(mlrAdjustGUI) *** Could not find property callback of uimenu copyScanMenuItem ***
(mlrAdjustGUI) *** Could not find property label of uimenu copyScanMenuItem ***
(mlrAdjustGUI) *** Could not find property callback of uimenu pasteScanMenuItem ***

For reference: everything works fine in earlier versions of Matlab (e.g. R2016a)

Problem with times-series file naming when writing files in quick succession

Hello,

I just came across a problem with how mrTools names time-series files it creates. I wrote an mrLoadRet analysis that separates interleaved frames and writes them to two separate files. The problem arose because the files get written quite fast after one another and some end up being written with the same file name as the preceding one (because the filename is a timestamp in seconds) and overwrites it.
I fixed this in my analysis function by adding a on-second pause between files, but I think there should be a more general fix at a more basic level (for isntance by adding a millisecond timestamp, or by forcing a one-second pause in saveNewTSeries.m?).
I don't have time to do it now, but I can look into it when I get a chance. I just thought I'd share the issue so it doesn't happen to others.

Issue mrLoadRet

Trying to run mrTool on MATLAB_2019b (works for a colleague).

It seems ti run fine, except for when I open the mrLoadRet GUI, the image display stay empty. It does successfully loads the data, as it shows the correct #volumes and TR, yet it won't display. Also when I start mrAlign and load, for example, the reference volume its load the anatomy but the display becomes black.

Issue in merging analysis

There appears to be a bug when merging analysis in mrTools. Here's one scenario that one can create the (undesired) result: 1) generate two scans in a group; 2) using the GUI, run one event-related analysis on the first scan; 3) again using the GUI, run another event-related analysis on the second scan. When prompted at the end, choose "Merge". This will save to disk the analysis. However, when inspecting the saved results, you will see that two fields are packed in the reverse order. Assuming you use the default name erAnal, then check erAnal.params.scanNum, and erAnal.params.tseriesFile, and you will find these fields are in a reverse order (i.e., scanNum=[2 1]). However, other structures in the erAnal, e.g., erAnal.params.scanParams, erAnal.d are packed in the normal order. This will cause some problem if one access those fields packed in the reverse order. Hope this can be fixed soonish.

In the mean time, one probably should not rely on the Merge functionality (I only tested this with event-related analysis so do not know how this behaves using other analyses). One possible work around is to always conduct the multiple analysis in a single shot (i.e., do step 1 and 2 together). MLR can handle different parameter settings for different scans, if needed. Just uncheck the box that says using the same setting for all scans (in the event-related analysis interface, at least).

Thank you for looking into this.

sub2ind no longer accepts NaNs in MATLAB R2024a, relevant to mrSub2ind

As of R2024a, MATLAB's sub2ind function throws an error when it encounters NaNs, presumably because of new functionality (see: https://www.mathworks.com/help/matlab/ref/sub2ind.html for more information). This function previously did not check for NaNs in prior iterations of MATLAB (R2023b and earlier), and MathWorks' current documentation makes no mention of this additional requirement.

To replicate: open any mrLoadRet session in MATLAB R2024a or later

Error stack:

Error using sub2ind (line 71)
Out of range subscript.

Error in mrSub2ind (line 28)
  linear = sub2ind(dims,x,y,z);

Error in refreshMLRDisplay>getROIImageCoords (line 702)
    baseCoordsLinear = mrSub2ind(baseDims,baseCoordsHomogeneous(1,:),baseCoordsHomogeneous(2,:),baseCoordsHomogeneous(3,:));

Error in refreshMLRDisplay>displayROIs (line 824)
    [x y s] = getROIImageCoords(view,roi{r}.roiBaseCoords,sliceIndex,baseNum,baseCoordsHomogeneous,imageDims);

Error in refreshMLRDisplay>dispBase (line 544)
  [roi,v] = displayROIs(v,hAxis,slice,sliceIndex,baseNum,base.coordsHomogeneous,base.dims,rotate,verbose);

Error in refreshMLRDisplay (line 152)
  [v img base roi overlays curSliceBaseCoords] = dispBase(gui.axis,v,baseNum,gui,true,verbose);

Error in mrOpenWindow (line 207)
    refreshMLRDisplay(view.viewNum);

Error in mrLoadRet (line 51)
v = mrOpenWindow('Volume',mrLastView);

Relevant change from sub2ind:

R2024a: sub2ind accepts mix of scalars and vectors for subscript inputs
sub2ind now leverages scalar expansion and accepts a mix of scalars and vectors for subscript inputs. For example, sub2ind(sz,[1 2 3],2) is now the same as sub2ind(sz,[1 2 3],[2 2 2]). Previously, the subscript inputs were required to be the same size.

Relevant code from sub2ind (lines 69-72):

if ~isempty(v) && (anynan(v) || min(v,[],'all') < 1 || max(v,[],'all') > siz_i)
    % Verify subscripts are within range
    error(message('MATLAB:sub2ind:IndexOutOfRange'));
end

As a result, the functionality of mrSub2ind no longer works in versions of MATLAB starting from R2024a, due to assigning x(badCoords), y(badCoords), and z(badCoords) a value of NaN.

Relevant code from mrSub2ind (lines 21-28):

badCoords = find((x < 1) | (x > dims(1)) | ...
		 (y < 1) | (y > dims(2)) | ...
		 (z < 1) | (z > dims(3)));
x(badCoords) = nan;
y(badCoords) = nan;
z(badCoords) = nan;

linear = sub2ind(dims,x,y,z);

switching to mrTools from mrVista

Hi all,

I was wondering if there were a set of scripts that take data processed in the vistaTools to mrTools? The key thing I would like to transport is the alignment parameters.. mrTools does this very nicely however its a little cryptic what mrVista is doing.

Thanks!

Motion Comp appears to reset FramePeriod on CNI data

Saw this during a motion compensation run:

Computing motion compensation for scan 9.  Please wait... 0took 54 hours 28 min 4 secs 448 ms
(cbiWriteNifti) Scaling data from single to float32
(viewSet) framePeriod set to: 0.000750 seconds

I couldn't immediately find where viewSet is being called from, but it looks like it's overwriting the framePeriod back to what's in the NIFTI file.

importing flat surfaces from freesurfer

Hi all,

I was wondering if there is a tool to import flat meshes made in freesurfer to mrTools?

If not I'll be happy to share this code when I write it up :)

Cheers!
Kevo.

select3d broken for matlab ver > r2014b

yay! another matlab upgrade problem. the function select3d() can't access the undocumented axis properties on lines 329 onwards.

Happens when a surface is loaded as base and mrInterrogator running (on mouseMoveHandler() events).

xform = get(ax,'x_RenderTransform');
offset = get(ax,'x_RenderOffset');
scale = get(ax,'x_RenderScale');

These properties got deprecated in latest release. It doesn't look like there's an obvious fix but the same info might be (apparently?) wrapped up inside a property called DataSpace. Still need to check this.

http://undocumentedmatlab.com/blog/customizing-axes-part-4-additional-properties`

(Future Compatibility Issue): Figure handles are no longer numbers as of Matlab 2014b

A number of functions related to figure control fail, some examples here:

When opening an individual voxel timecourse:

Undefined function 'real' for input arguments of type 'matlab.ui.Figure'.

Error in int2str (line 12)
x = real(x);

Error in newGraphWin (line 18)
figloc = mrGetFigLoc(['graphFigure' int2str(h)]);

When closing a window:

Undefined function 'real' for input arguments of type 'matlab.ui.Figure'.

Error in int2str (line 12)
x = real(x);

Error in closeGraphWin (line 19)
    mrSetFigLoc(['graphFigure' int2str(h)],get(h,'Position'));

It seems to be caused by Matlab no longer referring to figure handles as integers, instead it's necessary to call figurehandle.number.

roi2base

This function should convert and ROI in x,y,z coordinates to a base surface type=3, patches with vertices and triangles (similar to what we did to import fascicles). This is a function that takes an mrTools ROI structure and returns and mrTools base strucutre

base = roi2base(roi);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.