Getting Started

From NUTMEGwiki

Jump to: navigation, search

Contents

Development History

We are continually updating NUTMEG. Version 1.0 of NUTMEG was released in 2004, with several incremental beta releases approaching version 2.0 in 2007. The final 2.0b3 version is the current official version. The 2.0 beta releases added time-frequency analyses, improved spatial normalization and across-subjects statistics, functional connectivity analysis, and new denoising algorithms. Note that beta versions may contain many unfinished features, some offensive comments, and probably a few major bugs.

Version 3.0 is in the works, and a development version is available from the SVN repository (contact Sarang or Johanna if you would like access). It involves a new output structure to facilitate the merging of the two old viewers to a new output viewer called nut_results_viewer. Inverse methods are called from command-line and not dependent on gui variables. This version may also contain many unfinished features, some offensive comments, and probably a few major bugs.

Setup/running

NUTMEG runs on MATLAB 7.x and requires SPM2 (testing with SPM8 under development). Note that, as of MATLAB 7.2 (2006a), OS-wide language settings may affect the behavior of fread for characters; this can cause unpredictable results when importing raw data. For example, in Linux, setting the LANG environment variable to "en_US.UTF-8" should work properly for American English. However, Japanese and other Asian languages may be problematic.

Other requirements:

  • Signal Processing Toolbox needed for filtering functions
  • Image Processing Toolbox needed for graphical VOI selection
  • at least 1GB of RAM recommended (2GB for some specific applications such as TFBF)
  • developed under Red Hat Linux for Intel 32-bit (also tested/works on Open Suse 64-bit)
  • runs well on MacOS X and Windows 2000/XP (and Vista?)

SPM2 on Intel Mac and 64-bit Linux

We have repackaged SPM2 with mex files compiled to run on Matlab for Intel Macs and 64-bit Intel Linux... this should allow NUTMEG to run smoothly on these computers, though note that other SPM2 features have not been tested. Download it here.

Basic Documentation

And here is ye olde help info from version 1.0 -- most of it is now moved here to this wiki.

Opening NUTMEG

Add both NUTMEG and SPM2 to your path within Matlab, (either using 'addpath' command to temporarily add, or to File>Set Path to permanently add). Be sure to "add with subfolders" !!!

Furthermore, make sure the spm_defaults with analyze.flip=0 is AHEAD of SPM2 or SPM8 in your Matlab path.

Start NUTMEG by typing nutmeg or nm on the Matlab command line, to bring up the main GUI (graphical user interface). IMPORTANT!!! Be sure you have closed SPM before starting NUTMEG! You can run nut_fresh to clear out everything in Matlab if you are not sure. To ease file selection during your session, it is recommended that you change your working directory to the location your data exists. Image:nutmegGUI.png

For a new subject with a new MEG dataset, proceed to "Coregister MRI" to include the structural MRI, fiducial points, and digitized headshape (if available) for that subject. Digitized headshape information is completely optional, but may improve coregistration accuracy if you have it. Alternatively, if an MRI is not available, headshape information will be used to create an image for visualization. If no MRI or headshape is specified at all, activations will be displayed over a "blank" image volume.

At any stage of loading data and processing, you may click "save session" which will save your working session into a ".mat" file with a name of your choice. You may then exit out, and resume your work at a later time by clicking "open session" and selecting the saved file. This is especially useful for, e.g., saving coregistration and VOI selections for a given subject, while processing different MEG runs. It can also help you revert to a certain stage of processing if you make a mistake or experience a crash. We will refer to this file as "session.mat" later on.

Coregister MRI

Note that MRI coregistration is optional and this step may be skipped; if no MRI is loaded, activations will be displayed on a "blank" MRI volume using head MEG coordinates.

  • Click Coregister MRI

Image:nutmegcoreg.png

The above GUI appears when "Coregister MRI" is clicked. However, not all of the buttons will be enabled, as shown, right away. Each will be enabled as you load the necessary information to proceed to the next step.

  • Select subject's MRI (*.img file) and normalized MRI (w*.img file created by SPM) by clicking on appropriate buttons. [[Bil.SpatNormStrucMRI][More details on how to create spatially normalized structural MRIs]]

To load a subject's MRI, click "Change MRI" and a file selection box will appear. The image must be in Analyze format. Select the *.img file; the corresponding *.hdr file must also exist in the same directory. To first convert an image to Analyze from most other common formats, such as DICOM, we recommend MRIcro.

Select the appropriate image orientation (neurological/radiological) for your particular image volume. Please note that neurological orientation is necessary for 3D display of results (including head surface rendering and SPM's brain rendering.) You may use an image rotated within SPM, and NUTMEG will use the additional rotation matrix stored in the "imagename.mat" file associated with the *.hdr and *.img files. However, an image flipped in SPM may not coregister correctly (i.e. if any element along the diagonal of the rotation matrix is -1).

  • Fiducials and sphere center should be automatically loaded when you load the MEG dataset later, but you can manually import it here if you like -- this is the *.hdm file in the dataset.ds directory of interest. Fiducials can be double-checked by clicking on "show ____" or adjusted by clicking on "set ___".

If you do not have saved fiducials yet, first click on a point on the MR image where the left preauricular point is, then click "set left PA." Proceed for right PA and nasion. You may then review these locations by clicking "show ..." To save these points, click "Export fiducials" which will save these coordinates in a ".txt" file with a name of your choice.

If you have fiducials already coregistered with the MRI, you may load them with "Import fiducials" and then click on "show left/right PA or nasion" to check that they loaded and coregistered correctly. If the saved fiducials are ones you created by using the "set ..." buttons, then the file to load is the ".txt" file you created earlier. If your data is from a CTF system, you may also load predefined fiducials that are stored in the dataset's default.hdm file, or other *.hdm file you created from doing coregistration in CTF software, including one created by localSpheres command.

Note: If you used the exact nasion and PA points during MEG acquistion, you should indicate those points here. If you used localizing coils placed, for example, 1cm away from the PA points, you should indicate those shifted points here.

You may optionally extract a scalp surface from the MRI, and view the fiducials in 3D.

  • If you have digitized headshape information, you may load it at this step. You can then use it to reduce the error of coregistry between fiducials and the headshape derived from the structural MRI. You may also use it without, or in place of, a structural MRI. If you load the headshape first without an MRI, NUTMEG will then create a headshapename.img for you, and this will then be used in place of an MRI for VOI selection, viewing of results, etc.
  • Click Done.
  • Note that due to a Matlab oddity, you cannot do anything else in Matlab while the Coregister MRI box is open! For example, anything you type on the command line won't execute until you click Done to close the box.

Volume Selection

The volume will be automatically generated if you have included a spatially normalized MRI in the Coreg toolbox. This volume was carefully created on the MNI brain, and then will be mapped to the subject's MRI. This option is highly recommended to do if you plan to average results across subjects or other group-level analysis. If you only care about subject-specific results, the spatially normalized brain can be added later if you wish to report MNI coordinates.

If you don't have the spatially normalized MRI or wish to select your own VOI:

  • If you have the image processing toolbox, you can draw directly on the MRI to create the VOI.

First move your cursor on the image to a point where you have the best view of your region of interest to select. Then click the 'Manual VOI' menu option and 'Select VOI.'

You may select a region as large as you wish, within the memory and CPU constraints of your computer. We typically select one hemisphere and use a 5-8mm grid for quick initial analyses. Larger VOIs and smaller grid sizes result in exponential increases in computing time and memory requirements. Whole head VOIs with a fine grid may require more than 3-4GB of RAM and a lunch break.

The axial view will be outlined in red first, indicating the slice to select. Click once at the edge of your desired VOI to start selection; trace your desired region, clicking to set anchor points. Double-click or right-click to finish selection.

Note: if using newer matlab versions (after 2007a?), there is changed behavior of roipoly -- now need to right-click and select "create mask" to complete selection.

The region you selected in the axial section will now be highlighted in green, and the coronal slice will now be bordered in red. Select the coronal section of interest in the same way, and double-click or right-click when you are finished.

The green area now indicates the volume selected from both axial and coronal planes. The sagittal slice is now bordered in red to indicate the final slice to select.

Once you are finished, the final volume will be highlighted in green. A file save box will pop up, and you may optionally save your VOI to a ".mat" file for future use with other datasets. It can be useful to do this if you want to process different MEG runs with the same VOI, or different VOIs with the same subject. You may also hit "Cancel" to proceed without saving. Either way, the VOI is also part of your NUTMEG "session" and would be saved along with the rest of your data and computations when you "save session".

  • Without the image processing toolbox, an input box for coordinates will appear. Click around on the MRI in advance to figure out which coordinates make sense to include.


In general, if you have already selected and saved a VOI for this subject, you may load it by using "Load/View VOI" button on the main GUI. Hitting "Cancel" here will display the VOI currently loaded into NUTMEG, if available. Otherwise, selecting a saved VOI will load and display it.

Loading sensor data

Loading one dataset at a time is the general procedure, but if you are analyzing stimulus conditions separately within a dataset then need to load these individually. See section on weight computation for discussion of how this affects the weight computation.

We support CTF, BTi (4D-Neuroimaging?), and KIT/Yokogawa MEG formats including the lead field computation. We support Neuromag data to load it, but for now the lead field must be computed elsewhere (MNE or Brainstorm or ?) and loaded in. We also plan support for non-MEG datatypes, including scalp EEG (BrainProducts is currently supported) and intracranial EEG.

  • In the main NUTMEG window, load sensor data by clicking on Load MEG Data. Select the file with the MEG data (for CTF data, this is the *.meg4 file, and corresponding default.hdm will also load within that directory). (KIT/Yokogawa users, please next section for further instructions.) The dataset name should now be displayed on the main interface text box.

Recommended to go back to Coregister MRI to doublecheck that fiducials loaded properly.

  • If you would like to use active or control windows relative to a CTF Marker (e.g., button press), you can load the latencies of these markers with the NUTMEG menu Special, Load CTF Markerfile.... This will open a graphical user interface that allows you to select among all markers found in the current dataset and apply them to either the active or control window.

You may view the sensor data and manipulate it by clicking "View/Select MEG Channels." The following GUI will be shown:

Within this window, you may bandpass filter the timeseries, select specific channels, and view either an amplitude or power spatial plot for a given time range. These parameters will be remembered if you close the window and open it again. This window is for viewing/manipulating your data in the sensor-domain only.

You should use this tool to select the sensors you want to use for further analysis (lead field computation), and will be remembered within nuts.meg.goodchannels

Since the standard beamformers don't perform well with two neural sources highly correlated in time (such as bilateral auditory activation), it is currently recommended that you choose the sensors near the source of interest (e.g., right sensors for looking at right auditory cortex, and then process separately the left sensors for looking at left auditory cortex). Our lab has developed a coherent suppression technique to allow an accurate source reconstruction in spite of correlated sources (Dalal et al., 2004; Sahani & Nagarajan, 2004).

Importing data from Meg160 (KIT/Yokogawa Electric) software

Decide on the name for your data set; for the purpose of these instructions, the name will be "name."

Export your .sqd file from Meg160 (MegLaboratory) using the Export command under the File menu, Import and Export sub-menu.

Export All Channels in Text mode, TAB delimited. MEG channels are in Tesla; other channels will be ignored by Nutmeg, so units don't matter.

Save the Exported file as "name_export.txt"

To use Nutmeg, one needs to have co-registered within Meg160 the MEG coordinates with the head coordinates, officially through an MRI, although Meg160 allows the use of a digitized head shape in place of an MRI. The following instructions assume that you've recorded from the marker coils on a subject and co-registered the coil localizations from the marker .sqd file with the coil locations from a digitizer or that you've co-registered fiducial points from a digitizer with the marker locations. In addition, you've drawn a Sphere Model using that command from the Analysis menu in Meg160.

Under the Property menu choose "Channel Info." Under the File menu in the window that pops up, choose "Save As" and name the saved file, "name_sns.txt" Nutmeg will get the sensor locations in sensor space from this file.

Under the Property menu choose "CoRegistration Info." Under the File menu in the window that pops up, choose "Save As' and name the saved file, "name_matrix.txt" Nutmeg with get the coordinate transformation matrix between sensor space and head space from this file.

Under the Property menu choose "MRI Info." Under the File menu in the window that pops up, choose "Save As" and name the saved file, "name_sphere.txt" Nutmeg will get the sphere origin from this file.

When you hit the "Load MEG Data" button in Nutmeg, choose the name_export.txt file and make sure that:

name_sns.txt name_matrix.txt name_sphere.txt

are in the same folder as name_export.txt

Finally, if you are using EMSE Localizer to digitize the head shape of your subject and have a .hsp headshape file, you may hit the "Coregister MRI" button in Nutmeg, followed by the "Load Digitized Headshape" button in the Coregistration Tool and choose the .hsp file to use in place of an MRI.

Thanks to Alec Marantz for providing this documentation.

Personal tools