eXTReMe Tracker
Oct 242012
 

1. Convert the brain.mgz volume to analyze:

mri_convert $SUBJECTS_DIR/bert/mri/brain.mgz brain.img

2. Align brain.img with your functional data in spm (eg, func.img)

3. Create your spm statistical output (eg, t.img)

4. Create the registration file:

tkregister2 --s subjectname --mov meanswaf.img --regheader --reg  register.dat --surf orig

This will bring up the tkregister window with the orig volume. Hit the “Compare” button to see the functional. The green line will be the surface. Make sure the alignment is good (ie, the green line follows the bright intensity patterns in the functional). Hit the “Save” button to save the registration. This will create a file called register.dat. If you make modifications to the registration and then want to view or edit it later, re-run the above command WITHOUT –regheader. This requires a lot of manual tweaking to get the functional brain aligned with Bert brain.

5. View your functional data in the volume:

tkmedit subjectname orig.mgz -overlay spmT_0001.img -overlay-reg register.dat

6. View your functional data on the surface:

tksurfer subjectname lh inflated -overlay spmT_0001.img -overlay-reg register.dat

Adopted from spmPainting

Mar 052012
 

Here’s a quick chart I made for quick look-up for conversion between Celsius and Fahrenheit scale.

[°C] =  5/9 × ([°F] – 32)

A graphical lookup for conversion between Fahrenheit and Celsius

A graphical look-up for conversion between Fahrenheit and Celsius (click to view full size)

The bold marking are at multiples of 100 degree Celsius.

Apr 142011
 

Assuming the nifti toolbox is in Matlab path, we can get the 91x109x91 mask to have the same dimensions as the normalized images generated with bounding boxes.

If we are making a mask for hippocampus, first we save that mask from WFU Pickatlas. Then to make it 79x95x68 voxels, run the following small script.

x=load_untouch_nii(‘hipp.img’);
x=x.img;xdim=[1:6 86:91]; ydim=[1:6 102:109]; zdim=[1:11 80:91];
origin=[40 57 26]; datatype=16;
x(xdim,:,:)=[]; x(:,ydim,:)=[]; x(:,:,zdim)=[];
nii=make_nii(x, [2 2 2], origin, datatype);
save_nii(nii, ‘boxedhippo.nii’)

We can then use these masks for signal extraction or any further processing.

Mar 032009
 

I had to create a movie/animation out of a series of images that I had in my folder. There were several methods described on several forums which suggested using GIMP for creating GIF files from JPG or PNG files when one is using Linux. Now the problem was that I had 70 files in total and it would have taken me a long to time to add all those images to GIMP in order to create my animation file.

Then I read somewhere that we can actually create GIF images in command line mode using Imagemagick. But to do so you need to have Imagemagick installed on your system. To install it in Ubuntu, run:

sudo apt-get install imagemagick

This program has several features that would let you do all sorts of things with images. I was interested in converting a bunch of PNG files into an animated GIF file. To do so, we need to  rename the files in a way that they would lie in a sequence when arranged alphabetically (if you plan on doing it the easy way). Suppose you have files named slide_01.png, slide_02.png, slide_02.png….slide_xx.png, and you want to convert them to movie.gif, we run:

convert -delay 10 -loop 0 slide*.png movie.gif

The parameter delay inserts a desired delay between two consecutive slides. The number x used for delay inserts 10x milliseconds of delay between two frames. Loop parameter 0 makes it repeat infinitely.

If you had files with non-uniform names, then you need to input each of them in a sequence after the delay and loop parameters. Suppose you have file summer.jpg, fall, winter.jpg, fall.jpg and spring.jpg and you want to order them as fall, winter, spring and summer in the gif image seasons.gif with a 1 second delay between each of them, use:

convert -delay 100 -loop 0 fall.jpg winter.jpg spring.jpg summer.jpg seasons.gif

Here are some animations of numbers from 0 to 9 with varying delays.

The delay values specified the above cases were: 1, 5, 15, 25, 50 and 100.

gif animation with 10 millisecond delay

GIF animation with 10 millisecond frame delay

gif animation with 50 millisecond delay

GIF animation with 50 millisecond frame delay

gif animation with 150 millisecond delay

GIF animation with 150 millisecond frame delay

gif animation with 250 millisecond delay

GIF animation with 250 millisecond frame delay

gif animation with 500 millisecond delay

GIF animation with 500 millisecond frame delay

gif animation 1 second delay

GIF animation 1 second frame delay

=================