being updated for v01_r14 …
NIRS-SPM is a SPM5 and MATLAB-based software package for statistical analysis of near-infrared spectroscopy (NIRS) signals, developed at the Bio Imaging Signal Processing (BISP) lab. at KAIST in Korea.
prepare files needed by NIRS-SPM
- NIRS data (in csv format or nii format. For Hitachi ETG4000, you need “File out” the measurement data, not the Hb data, into csv format)
- (optional) Structural image (e.g.
xu.img
). I use SPM2 to do normalization and segmentation (below), but you can choose whatever tool you prefer.- normalize the image (use template
T1.mnc
) and get two files, wxu.img and xu_sn.img. This step takes 2 min. - segment the image (not the normalized image) into gray and white volumes and get 3 files (xu_seg1.img, xu_seg2.img and xu_seg3.img). They are gray, white, and CSF volumes. The first two images will be used in NIRS-SPM. This step takes ~6 min.
- normalize the image (use template
- (optional) Coordinate file (a plain text file, e.g. RealCoordinate.txt), from probe positioning system
This file contains 3 columns, with each row a 3-D coordinate of a point measured with 3D digitizer. The total number of rows is the sum of landmarker points (nasion, inion, etc) plus the number of optodes. You will have to specify the two numbers in NIRS-SPM.- If you don’t have 3d digitizer at all but you know the positions of each optodes in your structural image (e.g. you used vitamin E marker), you can simply find the positions using SPM’s display functionality and put into the file.
- If you don’t have MRI image at all, you can use a standard brain image. You need to check how well the registration is visually.
- If you don’t have MRI image, and you didn’t measure optode positions with 3D digitizer, but you take a picture of the subject, you can use a standard brain, and “guess” the optode coordinate with the picture.
- If you don’t have MRI image, or 3D digitizer measurement, or a picture, then you can use a standard brain, and guess, and cross your finger.
- The event onset timing and duration (in seconds). For example, [12 34 55 67] etc.
NIRS-SPM system requirement:
- MatLab (with graphic display)
- SPM5 (note: not SPM2)
steps:
- (optional) Login scuttlebutt (even you are on scuttlebutt computer)
ssh fmri@scuttlebutt -Y - Start matlab with graphic support and spm5 in path
e.g.
ml7spm5 -jvm &
- add NIRS-SPM folder into MatLab path
addpath('/net/cibsrdata/Volumes/SPNLData05/quarry/cuixu/NIRS/NIRS_SPM_v01_r14');
(You need to replace NIRS-SPM path to your own path) - Enter sample_data directory (optional)
cd /net/cibsrdata/Volumes/SPNLData05/quarry/cuixu/NIRS/sample_data
- run NIRS-SPM and the main window pops up
nirs_spm - Click “Convert” button, data conversion window pops up
- Select Hitachi ETG-4000
Select the csv file, conversion begins automatically. It will take ~20s
Click “Save .mat file” button, and save the file as “converted_NIRS.mat”
Close data conversion window. - (optional) Display NIRS data.
Click “Display NIRS Time Series” button in the main window. NIRS_TimeSeries_Viewer window pops up.
Click “Specify NIRS(.mat) file” button and select “converted_NIRS.mat”. Time series of channel 1 is displayed.
Click “Specify model parameter” button and input the vector of onsets and duration
Close NIRS_TimeSeries_Viewer window - Select “With MRI” and Click “Spatial registration” button, two windows pops up.
Select “T1_MRimage/uniform.img” as T1 image
Select “wuniform.img” as normalized T1 image
Then a SPM big window pops up and the subject’s T1 is shown.
Find point (-70 34 36) and click + (you will see the point is added into “Indicator Locations” window)
Repeat for other points (-82 -31 36), (-1 85 -15 nasion), (-8 -86 -58 inion)
In “Indicator Locations” window, enter 4 and 16 for “Indicator #” and “Optode #”
Click “Select Real Coordinate File” button and select file “RealCoordinate_txt_format.txt”. The locations will be displayed.
Click “Get Optode Pos. in MRI” button and select “T1_MRimage/uniform_sn.mat” file. Also select the gray and white file (“T1_MRimage/c1uniform.img” and “T1_MRimage/c2uniform.img”)
After ~30s the coordinates in MRI is calculated.
Click “View Channel Pos” button you will see the positions of channels
Click Save button and save the position as “channel_position.mat” - Click “Specify 1st Level” button and “NIRS_Specification” window pops up
Select nirs data file “converted_NIRS.mat”
Create directory “spm” and Select it
Select “Oxy-Hb”.
Click “Specification” and specify the following parameters
“hrf (with time and dispersion derivatives”
number of conditions: 1
name for condition 1: right finger tapping
vector of onsets: [42:51:501]*9.75
duration: 21*9.75
high-pass filter: 60
low-pass filter: Gaussian
Gaussian FWHM: 4
Correct for serial correlations? none
Then a big SPM window pops up with design matrix
Close the windows except for the main window - Click “Estimate” button in the main window, NIRS_Estimation window pops up
Select “Individual Analysis”
Select “SPM_indiv_HbO.mat” as SPM.mat
Click “Estimation” button. It will take 7 min. File “V_indiv_HbO.mat” is saved. - Click “Result NIRS” and NIRS_Results_Viewer window pops up
Select SPM_indiv_HbO.mat
Select channel_positoin.mat
Click “Contrast”, SPM contrast manager window pops up
Click “Define new contrast”. name: finger, type: t, contrast 1 0 0 0, click OK, click “Done”
After ~20s T map is shown. Click “View the thresholded T-statistic” and try different p-values. - Click “Result fMRI” and select SPM.mat in fMRI_result folder
(can’t get this to work now)
files required:
- NIRS_data_finger_tapping.nir
- RealCoordinates_txt_format.txt
- uniform.img : subject’s structural image
- wuniform.img : subject’s structural image after normalization
- uniform_sn.mat : the mat file produced by SPM during structural image normalization
- c1uniform.img : gray volume of segmentation
- c2uniform.img : white volume of segmentation
- SPM.mat (for fMRI and NIRS comparison)
- spmT_0001.img (for fMRI and NIRS comparison)
inside the files:
- .nir file is simply a text file. Row is time and column is channel.
- .csv file is also text file exported from Hitachi ETG4000
- RealCoordinates.txt is a text file with each row a point coordinate.
- converted_NIRS, or nirs data after conversion is a mat file with a single variable nirs_data. nirs_data is a struct. An example is:
oxyData: [5384x24 double] dxyData: [5384x24 double] fs: 9.7500 timeLength: 14 nch: 24 lightNum: 2 rawdataLength: 5384
- channel_position.mat, or the channel’s position after calculation is a mat file with a single variable, preproc_info. An example is:
wT1_info: [1x1 struct] rend_ch_pos: {1x6 cell}
wT1_info is the volume information of the normalized brain (you can get this info by spm_vol). rend_ch_pos is a cellarray. Each element contains a different view of the brain. Try
figure;imagesc(preproc_info.rend_ch_pos{4}.ren)
hold on;plot(preproc_info.rend_ch_pos{4}.rchn,preproc_info.rend_ch_pos{4}.cchn,'o')
You will see how the channel positions are displayed. - SPM_indiv_HbO.mat, containing estimation parameters and info
- V_indiv_HbO.mat, a matlab mat file containing variable V_nirs, which is a sparse matrix.
related links:
Hi Xu,
This looks really great!
Is the NIRS-SPM script for converting raw data to hemoglobin specific to continuous wave nirs devices, or can it be adapted for frequency domain?
Thanks!
@Megan
I believe it can do both – but NIRSPM developer should have a definite answer.
Hi Cui,
thanks for these detailed instructions.
I have another question:
how about the baseline correction. i have more than one time point that i measure a baseline to use it as a contrast to a motor condition. in the dialog in NIRS-SPM “enter baseline”: can I enter there a vector for many baselines and does NIRS-SPM calculate a mean baseline then?
thank you, ingo
@ingo
ingo,
Unfortunately I don’t know the answer. I suggest you contact NIRS SPM developer for an accurate answer.
Thank you a lot for this work, is very useful, specially when you are a beginner. I have a question about the group analysis: I am trying to do the group analysis and there is an option that I have not clear what is the minimum number of overlapped individual subjects. If I have already 9 subjects, how should I determinate ?
Thank you
Hello Xu,
I’m using SPM5/8 and NIRS_SPM software and ETG-4000, I’m having trouble to find the SPM_indiv_HbO.mat for SPM_nirs.mat function in the Results NIRS button. can you tell me where to find it?
@Eidan
Eidan, I suggest you contact NIRS SPM’s developer. I have not used the software for a long time and not sure if they have updated it.
Could you send the whole NIRS-SPM files to me?Cause I can’t access the download pages.My e-mail address is [email protected] you very much.
@neuron
Please try http://bispl.weebly.com/nirs-spm.html#/ and https://www.nitrc.org/projects/nirs_spm/
Can I start NIRS-SPM without the data files?Thank you.Hello Xu.
When I input the NIRS-SPM in the command window of MATLAB,it shows Undefined function or variable ‘nirs’.But I’ve already set the path in a correct way.I mean, Is there need any connection between my computer and NIRS machine?And how can I work it out?
Thank you.
@neuron
I suggest you contact NIRS SPM’s developers directly. I have not used the software for a long time.
I don’t think you need to connect to the nirs machine to use NIRS-SPM.
Hello Xu,
Thanks for detailed steps.
I was working on the nirs_spm temporal processing. And my time_series views doesn’t display the Load button. I tried to debug and look like the panel covers all the below button. Could you please share your nirs_timeseries viewer.m file .
Thank you
Binal,
I belive NIRS_TimeSeries_Viewer was provided by NIRS-SPM. Please feel free to ask the develop for the code.
Xu
I downloaded entire folder from spm website. Looks like there is bug with this file during update.So was asking if you could provide the file.
Thanks
Please check your email.
Thank you so much Xu for providing the matlab file and quick response.
I would need the timeseries_viewer.fig file also for the code to work.
Thanks again. I really appreciate your time and help.