The very first thing to do is to create a locale file using copylocale utility. e.g. copylocale en_US zh_CN
More detail can be found in http://www.herrodius.com/blog/123 and here is a copy from there:
- open a command line (run as administrator in Vista!)
- go to the “bin” folder in your Flex SDK installation folder
- run the copylocale.exe tool for each locale, this will copy the localized framework files from one locale to another (copylocale en_US nl_BE)
- check FLEX_HOME\frameworks\locale to see if the folder for your new locale has been created
[update]
To call a function when a property of an object changes, use the following code BindingUtils.bindSetter(callThisFunction, aObject, "prop");
Note, callThisFunction is a setter (need one argument and return void)
In MXML it’s easy to bind data using {}. Sometimes you may prefer to use actionscript as it is more efficient. How to achieve data binding in actionscript? The ultimate question is, how do you know when data changes? Here I only focus on complex data (i.e. custom Object. e.g. a Person Object which has two variable, name and age) instead of simple ones (String, int, etc). For complex data, there are two types of changes:
Reference change
This is caused by new operator. (e.g. p = new Person('Mike',32);)
Property change
This is caused by directly changing the properties (e.g. p.name = 'John' or p.age = 20;). The reference of the object is not changed.
We apparently want to detect both changes. First, we need to use [Bindable] metatag for the Person class. Otherwise, we won’t be able to detect property change.
package
{
[Bindable] // necessary if you want to detect changes when individual properties are changed but the reference not changed
public class Person
{
public var name:String = '';
public var age:int = 0;
public function Person(name:String=null, age:int=undefined):void
{
this.name = name;
this.age = age;
}
}
}
Then we create our custom component using actionscript only. This custom component, we call DisplayPersonComponent, is to display name and age in TextInput. It also has a member variable person:Person.
package
{
import mx.binding.utils.BindingUtils;
import mx.binding.utils.ChangeWatcher;
import mx.containers.VBox;
import mx.controls.TextInput;
public class DisplayPersonComponent extends VBox
{
[Bindable]
public var person:Person;
public var nti:TextInput; // to display name
public var ati:TextInput; // to display age
public function DisplayPersonComponent()
{
super();
nti = new TextInput();
ati = new TextInput();
this.addChild(nti);
this.addChild(ati);
ChangeWatcher.watch(this, "person", onReferenceChange);
}
private function setupBinding():void
{
BindingUtils.bindProperty(nti, 'text', person, 'name');
BindingUtils.bindProperty(ati, 'text', person, 'age');
}
private function onReferenceChange(event:Event):void
{
setupBinding();
}
}
}
For comparison, let’s create the same component using mxml (which is much shorter) and call it DisplayPersonComponentMX.
An image file can be saved in different formats such as uint8 or int16, etc, based on different number of bytes used for each voxel. How to convert between them? Here is one solution using SPM functions (no need SPM’s interface). Assume img1.img is the original image with datatype int16, img2.img is the file you want to create with datatype uint8.
V=spm_vol('img1.img');
disp(V.dim); %you will find the last element is 4
V2=V;
V2.fname='img2.img';
V2.dim(4)=2;
M=spm_read_vols(V);
spm_write_vol(V2, M);
Explanation:
Variable V.dim is a 1×4 vector. The first three are number of voxels (or dimensions) along x,y and z direction. The last element (4th) is the number of bytes used for each voxel and it is this variable we want to change.
I myself find the following 3 SPM functions are extremely useful and use them a lot:
V=spm_vol('img1.img'); % read header information of an image file
M=spm_read_vols(V); % read the data (voxel intensity) from an image. The result is a 3D matrix with each point corresponding to a point in brain.
spm_write_vol(V2, M); % write data to an image file.
Check out here to see how to convert images with different formats (e.g. ANALYZE, Nifti, DICOM etc)
The Anterior Commissure (precommissure) is a bundle of white fibers, connecting the two cerebral hemispheres across the middle line, and placed in front of the columns of the fornix. On a sagittal section, it is oval in shape, having a long vertical diameter that measures about 5 mm. (ref: wiki)
The posterior commissure is a rounded band of white fibers crossing the middle line on the dorsal aspect of the upper end of the cerebral aqueduct. (ref: wiki)
Today I listened to Frans de Waal’s talk on empathy in primates. It’s quite interesting. He wrote several popular books including “Chimpanzee Politics”.
The knowledge of brain-function mapping is accumulated … The Knowledge of brain-function mapping is accumulated … (get rid of the in front of knowledge)
Don’t start a sentence with it, this. Instead, specify what it is.
Don’t start a paragraph with “at the same time”. At the same time of what?!
When writing a grant/fellowship, use their language (e.g. if they say ’specific plans’, you should not say ’specific aims’
Use ‘brain disorder’ instead of ‘mental disorder’ (well, this should depend on the context)
The overarching goal of this study is to develop …
Success in the enterprise will provide important theoretical and clinical insights and will launch future interdisciplinary basic, clinical, translational pediatric neuroscience research.
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.
(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:
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.
lazy quantifier: Add a question mark (?) after any quantifier to change it to what is known as a lazy quantifier. For example, the following regular expression, which uses the lazy *? quantifier, matches <p> followed by the minimum number of characters possible (lazy), followed by </p>: