Skip to content
Dec 20 14

SPM8 custom PET template creation script

by manuel

Download script here.

If you want to make your own SPM8 custom PET template to do PET normalization (for example with 18F-FDG)  and are looking for a script that does this with one command, today is your lucky day!  After some googling around and reading through different instructions, I decided to write my own batch script. It is mostly based on a post by Alexander Hammers from June 18 2009 in the SPM mail group.

All you need is a bunch of normal PET images (at least 10, the more the better) with the corresponding MRI images. I ended up using some patients too, since I didn’t have enough normal PET+MRI images.

First, put the mktemplate.m script in your Matlab folder. Change the location of the spm8 folder on lines 45-47 to match your settings.

Rename PET images to PET_$.nii, and MRI images to MRI_$.nii, where $ is the patient ID (like PET_001.nii and MRI_001.nii). Put all images in one folder. Navigate to that folder in Matlab and just type mktemplate. 😉

The script will search for all MRI_*.nii files in the folder and assume corresponding PET_*.nii files. For each pair it will run:
1. coregistration of PET onto MRI
2. segmenation of MRI (we are only interested in the sn.mat file containing the variables used to transform the MRI into standart MNI space)
3. normalization of PET image using the sn.mat file generated above

After that, it will create a soft mean of all the PET images (8bit UINT) and smooth the result with a 8mm FWHW.

The result is a file called s08customPET.img/hdr. Just move it to the spm8 templates folder and rename it. I used MRIcron to transform it to .nii so it’s like the other template files.

comparisson

Hope this helps and please post comments if any questions!

Nov 14 14

Remove spaces from filename in Mac

by manuel

This is just a small code to remove spaces from filenames in a Mac bash terminal:

Change *.nii to find other type of files. Put a – or _ between the two commas before the g to substitute the space by another symbol.

Oct 30 14

Google script: substitute blank cells by “x”

by manuel

Today I had a big spreadsheet with quite a few missing values, which I wanted to substitue by “x”. So I decided to write my first google script!

I’ts pretty straight forward: in your open spreadsheet, go to Tools > Script Editor and put in the following code:

Close and reopen your spreadsheat. You will see a menu “My Scripts” after “Help”, just click on the function and wait for it to finish!

Jun 3 13

Simple solar panel + cooler setup

by manuel

10w-solar-panel-front     Free-shipping-cooler-heatsink-axial-Cooling-Fan-for-NMB-12025-24V-0-31A-4710NL-05W-B50

 

Just wanted to share my first experience with solar power!

I have a room which isn’t very well ventilated, so I decided to build in a small cooler. To keep it simple, I decided to connect the cooler directly to the panel.

The panel is 5W and can produce 0.28A at 18V with maximum sun. I bought it on aliexpress.com and it was 20 USD with free shipping 😉

Related power 5W
Voc 22.41V
Vop 17.9V
Short circuit current (Isc) 0.3A
Working current (Iop) 0.28A
Output Tolerance ±3%
Temperate coefficient of Isc (010+/- 0.01 )%/
Temperate coefficient of Voc – (0.38 +/-0.01 )%/
Temperate coefficient of power Voc -0.47%/?
Temperature range -40?to +80
Frame Heavy duty aluminum
Kind of connection waterproof junction box, can be customized
Guarantee of power 90% with in 10 years  80% with in 25 years
Kind of glass and its thickness Low Iron, high transparency tempered glass of 3.2mm
SLA Battery Voltage 12V
Size 255 x 194 x 15mm

The cooler is a 24V, 0.31A cooler, so at 18V it will use 0.24A. Perfect fit for the panel!

The system works great. At about 8 am the cooler starts spinning and runs continuously until about 4 pm!

May 25 13

Arduino Yogurt Maker

by manuel

FWIZETKHH2VZD8B.LARGE

These days I was reading an interesting post on how to make yogurt “by the gallon” (http://www.instructables.com/id/Yogurt-By-The-Gallon/). One thing needed was to maintain a rather constant temperature of 43ºC (110°F), so the bacteria can grow properly. Though you can buy commercial yogurt makers, they aren’t big enough for a gallon of yogurt. Besides, it’s cheaper (and way more fun) to build one yourself.

Checkout this post I made on instructables.com.