Noise Detection

From BrainImagingCenter
Jump to: navigation, search

Antonia Hamilton's Noise Scripts

Signal to Noise Scripts (for SPM2) (for SPM5)

SNR_SD consists of two scripts. One for calculating average signal, standard deviation and SnR on a run by run basis (snr_sd.m) and one for batching multiple subjects (snr_sd_batch.m). The formula for these scripts was originally based on a posting to the spm list by Bas Neggers with modifications for DBIC naming conventions, outputting raw and preprocessed data, outputting figures (.ps) and for fixing SPM2 scaling issues on certain image types. If you are using an older version of the scripts (pre-2008) please upgrade as some minor fixes have been added.

The current version outputs img/hdr files for the average signal, standard deviation, SnR (avg/sqrt(sd)) for both raw and preprocessed data. If no preprocessed data is available the script will work only on raw data. Output files are stored in a directory called SNR. Finally a postscript file containing select slices for each run is output to the subject's directory. Note the postscript file is only created if preprocessed data exists.

To calculate SnR: From the root folder of a given study open matlab and type snr_sd_batch and select the subject(s) for which you would like to calculate SnR(both single subjects and multiple subjects can be run from the batch tool). snr_sd will run on each selected subject until finished. Output files will be stored in ./SNR and a postscript file will be created in the subjectID folder.

Visualizing SnR: snr_sd.m will output a postscript file which offers a quick overview of the SnR and Standard Deviation in a few select slices for each run. For a more detailed view it is recommended you examine img/hdr files in MRICRO or MRICRON which can auto-scale image intensity to allow for better visualization of the SD and SnR maps.

Here are some examples of good and bad SnR and SD images.

Good SnR and low variance across entire brain.(09jan08)
Good SnR but column artifact. This occurs on both the current and previous 3T.(28may07)
This is what the data look like when the coil is ready for the curb.(14jul06)
Zebra/thumbprint artifact.(17jul06)
Frontal quadrant giving bad signal.(31jul07)

SIGVOX Voxel signal plotting device

SIGVOX is a simple gui for plotting the signal timecourse of a single user selected voxel. Sigvox is designed to work in conjunction with the Signal to Noise scripts and, for the moment, will only work if you have previously run snr_sd and have a proper SNR directory. To run sigvox ensure that the sigvox directory is in your matlab path (copy it to your home directory/matlab and edit mystartup.m to add SIGVOX to your matlab path). From within a study directory, type sigvox at the matlab prompt. Navigate to one of your SNR folders (for the moment SWUABOLD_AVERAGE, SWUABOLD_SD or SWUABOLD_SNR only, sigvox will not yet work on raw bold snr files). Double click on an image and the image viewer will load orthogonal views of the image. Click around those views to move the crosshair and sigvox will plot the timecourse for that voxel (based on the SWUABOLD timeseries for that run).

The current version will only plot the signal for files preprocessed with SPM2. In addition to the signal plot, it will also display summary statistics for that voxel (Min/Max, SD, Mean). Finally, it will plot the movement parameters for that run, this allows you to ensure that any abnormalities you see in the signal isn't correlated with movement.

It's still early days, so if you see any bugs, blitz me (ddw). One minor issue I've just noticed is that moving around the coronal plane will also cause a shift in the y-plane. In other words the coronal isn't locked to x-z movement only. I'll fix this asap. Nevertheless, you can select any voxel by relying on the sagital and axial views. Also, there's a number of kludges to make it more user friendly, such as automagically figuring out subject name and run numbers, but it may crash if you have very atypical subject naming schemes. I've tried it on a number of studies and a few different naming schemes and no problems yet.

Voxel signal and movement parameter plots on a mediocre SnR map

MELODIC Independent Components Analysis

To perform an ICA noise analysis:

1. You must concatenate your myriad Analyze files (.hdr and .img file pairs) into one large NiFTI file. To do this navigate to your imaging data folder and type the following command:

fslmerge -a output_filename input_bold*.img

Be sure to include the * so that fslmerge will grab your entire run. Also, in earlier versions of FSL the merge command was titled avwmerge. If one doesn't work, try the other.

2. Now we will setup the MELODIC parameters. Type melodic_gui to bring up the graphical user interface. Here are some recommended parameters for each tab:

- Change nothing. Brain/background threshold at 10% is usually fine.

- Change the number of inputs to the number of ICA analyses you wish to do. For instance, you could do several runs or several subjects all at once.
- From there, click 'Select 4D data' and identify each of the NiFTI files you created in step 1.
- Output directory is where you want the results to go.
- Only use 'Delete volumes' if you did not have any dummy shots in your acquisition. If this is the case you can then use this box to delete the first few TRs of data.
- TR is your TR. Why did I even write that out?
- Finally, select a period cutoff for a high pass filter. This will improve the final ICA results by eliminating drift and other slow noise. The default cutoff of 100s usually works well unless you have a specific reason to change it.

- Apply motion correction if the data has not been realigned. The tool 'MCFLIRT' is FSL's motion correction algorithm.
- You can apply B0 unwarping if you wish. If you don't know what it is and haven't set it up before then don't worry about it.
- Slice timing corrections can be accomplished in the pre-stats. Here at Dartmouth we usually acquire slices in an interleaved fashion.
- BET brain extraction will get rid of non-brain voxels, speeding up and increasing the accuracy of the resulting ICA analysis.
- Spatial smoothing is how large of a smoothing kernel to apply to the data before the ICA analysis has begun. Typically this can be the smoothing size you apply to your data for GLM analysis.
- Leave intensity normalization off.
- For temporal filtering I typically only use the highpass filter.

You can use this tab to normalize your data for group analysis or to have your ICA results in the same space as your GLM results. For a simple noise analysis you can turn all of the options off to do the ICA in the image's native space.

- Variance normalization will help the estimation be more influenced by variability in the signal instead of the mean. You should keep this on.
- Automatic dimensionality estimation will try to determine how many components of signal are in the data. Turning this off may result in overfitting of the data.
- The final option on this tab is the kind of ICA you want to accomplish. In a noise analysis you are usually aiming for a single-session ICA. To do a group analysis of all data fed into MELODIC you can do either temporal concatenation of Tensor-ICA.

- The threshold is the voxel-wise probability of activation. Select an appropriate level to examine your data. The default of 0.5 works well for doing noise analyses.
- The background image is what image you would like your results displayed on. Simple. Easy.
- I generally select to output the full stats folder.
- The timeseries model and contrast boxes are for use in conjunction with FEAT-based GLM analyses. If you use FSL in the linear analysis of your data this might be handy for you.

3. Select the 'Go' button on the GUI and go out for coffee.

4. Look at your results. MELODIC outputs its results to a html file viewable by any web browser. Just drag the report.html file to your browser window and have a look at your components.

Artifact Check toolbox