Search Comments and Ratings

go

   
Date File Comment by Comment Rating
14 Feb 2014 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

you can't do it. check faq.pdf when you need load_untouch_nii or load_nii

Comment only
12 Feb 2014 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

because it's not the business of view_nii to interpret and apply header info.

Comment only
31 Dec 2013 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Nicolas, please tell me what is the exact "clues" or "messages" that confuse you. In addition, please tell me what you try to do.

Comment only
19 Nov 2013 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

You can use "load_untouch_nii / save_untouch_nii" pair. Here's an example:

nii = load_untouch_nii('avg152T1_LR_nifti.nii');
nii.hdr.hist.descrip = 'Mengye';
save_untouch_nii(nii, 'new_avg152T1_LR_nifti.nii');

Unless you touch nii.img by yourself, e.g. nii.img(1)=0, it will not be changed, although it is also loaded and saved. Only the header (nii.hdr) is edited in the way you make the change.

In addition, if the input file is in Analyze 7.5 format, the output will be kept in Analyze 7.5 format. If the input is in NIfTI format, the output will be kept in NIfTI format.

That is why I have "load_untouch_" as well as "load_" feature. However, in most case, you want to use "load_" feature, since you don't want to interpret affine matrix in the header, and make all sorts of flipping and rotation by yourself, do you?

Comment only
11 Nov 2013 Resampling volume or image with affine matrix Use affine matrix to convert 3D vol or 2D img to orthogonal one with corresponding affine matrix. Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

The output volume is determined by the original volume, the affine matrix, and the new voxel_size that you choose. If any of the above inputs change, the output will also change. Otherwise, the output should be consistent.

The difference in dimension between output volume and original one is obvious. Just think about a unit square in 2D plane with dimension of [1 1]. If you rotate it 45 degree, you have to use a dimension of [1.414 1.414] to hold the same square. However, the distance from origin to edges are still 1.

In order to properly crop the transformed volume, you need to keep in mind that we are focusing on the unit of distance from the originator based on the affine matrix (e.g. millimeter), and don't worry about voxel size or its dimension. Since I have not used it for registration, I don't have detail procedure for you.

Comment only
08 Nov 2013 Resampling volume or image with affine matrix Use affine matrix to convert 3D vol or 2D img to orthogonal one with corresponding affine matrix. Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

The new_img is interpolated from the old_img. Therefore, there is no exact mapping between old point and new point. I agree with your thoughts. However, keep in mind that we are talking about voxels (little cubic, with voxel_size) rather than points (with no size). Otherwise, you don't need this program, and a plot3 is enough to do affine transformation for points.

Comment only
30 Aug 2013 geotiffwrite Write a 2D or 3D array to a single or multi-band GeoTIFF file Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

No, it is not a typo.

"bit_depth" value -16 & -32 were designed to expand datatype to "16-bit unsigned integer" & "32-bit signed integer".

If "bit_depth" is -8, it will be treated as 8 anyway, since only abstract value is considered. However, if it is 1 or -1, according to TIFF Revision 6.0 (Final-June 3, 1992), "SampleFormat" field has to be set to "undefined data format", since it is binary monochrome data.

If you look further down a little bit to line 932, you will find how I write data strip based on "bit_depth" value.

Comment only
07 Aug 2013 geotiffwrite Write a 2D or 3D array to a single or multi-band GeoTIFF file Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Please check: http://research.baycrest.org/~jimmy/geotiffwrite

You need to add:

option.ColorMap [Nx3 array]

Where N = 2^bit_depth, and bit_depth can only be 8 or 16. Values in option.ColorMap range from 0 to 65535, and value 0 in image points to the first row in the ColorMap. Columns in option.ColorMap are [R G B]. Black is represented by [0 0 0], and white is represented by [65535 65535 65535].

Comment only
05 Jul 2013 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Data for "plot" only contain the coordinates information, while data for "make_nii" need intensity value which is assumed to be distributed on a grid with its coordinates from 1 to the dimention of the grid. In addition, unlike plot, coordinates for images contain only the integer. Therefore, you cannot directly extract the data from a plot and make it to an image.

Export your plot data to an image would be an easy alternative. I think you already did good. All you have to do is to hide the background image and the axes before you export the plot to an image. Here's how to do so:

1. Before export, use mouse click your plot (make it active);

2. Hide the axes by running:

set(gca,'visible','off');

3. Hide the background image by running:

h = get(gca,'child');
for i=1:length(h)
if strcmpi(get(h(i),'type'),'image')
set(h(i),'visible','off');
end
end

4. Export the plot to an image. Now it does not have the background and axes.

Comment only
14 May 2013 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

"collapse_nii_scan" is used to integrate multiple single-volume NIfTI or ANALYZE files into one multiple-volume NIfTI file. In your case, if you want to concatenate two 4D NIfTI images into one 4D NIfTI images, you should apply "expand_nii_scan" to your both 4D images. All volumes must be in the same folder, and make sure the file name is correctly renamed (i.e. from 001~999 instead of 1~999). Then, apply "collapse_nii_scan" to all those expanded volumes in the specific folder, and you will get a concatenated 4D NIfTI image file.

Comment only
14 Sep 2012 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Hi Zhi:

"collapse_nii_scan.m" will do the job.

Hi Samiy:

This tool can not be used to extract spinal cord. However, once you extracted it and saved into another Analyze/NIfTI file, this tool can load the data into MATLAB for further processing.

Comment only
11 Jul 2012 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Received the image, and it is a special RGB data type one. The nii.img ranges from 0 to 1 as usual, but the output value needs to be scaled by (glmax-glmin)+glmin.

Comment only
10 Jul 2012 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Would you please send me this image, so I can take a look into it for you tomorrow afternoon.

Comment only
30 Apr 2012 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Sure Mark. You need a reference image by the way, so you can see what will happen before and after you apply the transformation matrix. Here's the example:

1. Download "avg152T1_RL_nifti.nii" from NIfTI site. I use it as reference image.

2. View how the reference image looks like: nii=load_nii('avg152T1_RL_nifti.nii');
view_nii(nii);

3. Assume that I have a Transformation Matrix, which will let the reference image turn 30 degree counter-clockwise on XY plane, here will be the matrix: T=[cos(pi/6) -sin(pi/6) 0; sin(pi/6) cos(pi/6) 0; 0 0 1];

4. Get old_xyz from reference image: rl=load_untouch_nii('avg152T1_RL_nifti.nii');
old_xyz=[rl.hdr.hist.srow_x(1:3);rl.hdr.hist.srow_y(1:3);rl.hdr.hist.srow_z(1:3)];

5. Apply your transformation matrix, and save new_xyz into a new image: new_xyz=T*old_xyz; rl.hdr.hist.srow_x(1:3)=new_xyz(1,:); rl.hdr.hist.srow_y(1:3)=new_xyz(2,:); rl.hdr.hist.srow_z(1:3)=new_xyz(3,:); save_untouch_nii(rl, 'rl30.nii'); Now you already have the "rl30.nii", which is a transformed NIfTI image can be used anywhere.

6. In order to view this image using my toolbox, you need to reslice it: reslice_nii('rl30.nii', 'rl30b.nii'); Now, you can load and view the rotated image: rl30b=load_nii('rl30b.nii'); view_nii(rl30b);

Hopefully this answers your questions.

Comment only
26 Apr 2012 geotiffwrite Write a 2D or 3D array to a single or multi-band GeoTIFF file Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

You need to use MATLAB's geotiffread to read L7 file into matrix, with all attributes. Then find out the index of your sub-region, and assign the sub-region to a new matrix. You can now use the make_option option in my package to select optional fields. However, you need to match the attributes that you read, and select the correct fields by yourself in order to create the optional fields to be used in my geotiffwrite. Since I don't have Mapping toolbox, I am afraid that I cannot provide you with more details.

Comment only
26 Apr 2012 geotiffwrite Write a 2D or 3D array to a single or multi-band GeoTIFF file Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

My geotiffwrite can only write a rectangular dataset into the file. As long as your sub-region is a rectangular dataset, you should be able to write it into a separate file.

Comment only
19 Apr 2012 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

To reply your first comment: The problem is that you mixed "make_nii" with "_untouch_" version. If you use "make_nii" to get NIfTI structure, it has to be saved using "save_nii".

To reply your second comment: If you know NIfTI structure well, sure you can modify it and then use "save_nii" to save it. You can even save "non-orthogonal" NIfTI structure to the file with "save_nii".

The reason that I interpret the header with "load_nii" and limit it to "orthogonal" transformation is all about convenience, at least for my work.

BTW, if you take the original NIfTI file, and bring it to other software to display (e.g. SPM), they will also reslice it for you.

Thank you very much for your rating!

Comment only
28 Mar 2012 geotiffwrite Write a 2D or 3D array to a single or multi-band GeoTIFF file Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

MATLAB finally has its own "geotiffwrite" function. So I suggest you use its geotiffread / geotiffwrite pair to load your Antarctica background, and superimpose your ship track data on top, and then re-write the entire data into GeoTIFF format using Matlab's geotiffwrite function.

I am currently no longer working in GeoScience field, so I am afraid that I cannot provide you with more useful advise.

Comment only
01 Mar 2012 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Got your data, and did the following test using "analyze75read" "load_untouch_nii" and "load_nii", here the results:

a1=analyze75read('dxx.img');
max(a1(:)), get 3.3943e-08

a2=load_untouch_nii('dxx.img');
max(a2.img(:)), get 3.3943e-08

a1=load_nii('dxx.img');
max(a1.img(:)), get 3.3943e+04

check: a2.hdr.dime.roi_scale
get 1.0000e+12

You told me that you got a voxel value of 1.089e+12 using "analyze75read". I cannot duplicate your result.

Comment only
29 Feb 2012 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Without more detail, I cannot duplicate your problem. Please send me your data that indicates it. On the other hand, I wish you could take a look at my web page to better understand this tool. In order to display, you must use "load_nii" instead of "load_untouch_nii". i.e. your data is interpreted properly (touched). There could be many cases, e.g. scale factor is specified in the header file, your data has different orientation, etc. However, in no situation it treats double datatype differently.

Comment only
16 Feb 2012 Resampling volume or image with affine matrix Use affine matrix to convert 3D vol or 2D img to orthogonal one with corresponding affine matrix. Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

I think you mean that the dimension of the output matrix is different from the input matrix, which is correct.

Think about you have a cubic, and you rotate it 45 degree along Z axis. If we the element size the same, the dimension of X & Y should be at least sqrt(2) larger than the original X & Y dimension, since the new X & Y dimension is equal to the old diagonal.

In addition, there will be some extra elements in the new corner, which will be assigned a value of [bg], which is 0 by default.

Please let me know if you still have difficulty to understand this.

Comment only
17 Jan 2012 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

I never have such a function called "read_nii_img". Please read all functions and usages from:

http://www.rotman-baycrest.on.ca/~jimmy/NIfTI

Comment only
19 Dec 2011 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

It seems that "load_nii_hdr" in "apply_fsl_transformation_matrix" has been modified. It should look like this "function [hdr, filetype, fileprefix, machine] = load_nii_hdr(fileprefix)". i.e. It should have 4 output arguments, which is exactly the same amount as "load_untouch_nii" asked for.

Comment only
16 Dec 2011 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

NIfTI supports both ".nii" and ".img/.hdr" file extension. If you do not provide any file extension, it will look for ".img/.hdr" files by default. Therefore, you can easily solve your problem by provide appropriate file extension. e.g. nii = load_nii('filtered_func_data.nii');

Comment only
22 Nov 2011 geotiffwrite Write a 2D or 3D array to a single or multi-band GeoTIFF file Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Please notice that the values in colormap range from 0 to 65535 (instead of from 0 to 1). So black is represented by [0 0 0], and white is represented by [65535 65535 65535]. If you put [1 1 1], it will be black. Please see more details from my web site: http://www.rotman-baycrest.on.ca/~jimmy/geotiffwrite

Comment only
20 Oct 2011 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

I assume that you have a series of 3D NIfTI (or Analyze) files with the same header information (i.e. same dimension, voxel size, originator, ... etc.), and you want to integrate it into a single 4D file with time series in the file.

If this is the case, you can use my "collapse_nii_scan.m" to do so. Type help collapse_nii_scan to get more information.

For file extension, this function will follow whatever you have. i.e. you will still get a single .hdr/.img file afterwards.

Since all NIfTI compatible software should be able to load a 4D NIfTI (or Analyze) file, we do not support any conversion from .hdr/img to .nii file.

Comment only
31 Aug 2011 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

You are not supposed to use "load_nii_hdr.m" & "load_nii_img.m". Both are internal functions, and are not supported when you call them directly.

If you want to take look at the header information, please use "load_untouch_header_only.m".

If you would like to change the voxel value, please use "load_nii.m" to load the NIfTI file, and then use "view_nii.m" to edit voxel value at crosshair (under "Edit" tab), and then click "Save displayed image" under "File" tab.

The reason of inconsistency in your case is caused by the scaling factor in the header that was not properly interpreted by yourself.

Comment only
30 Aug 2011 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

This is because those parameters & scaling have been interpreted & applied to the image. It is what NIfTI loader supposed to do.

If you want to interpret header by yourself, feel free to try the following commands:

x = load_untouch_nii('b0.hdr');
save_untouch_nii(x, 'b0xx.nii');

For more details, please carefully read all the instructions through, which can be found on my web page:

http://www.rotman-baycrest.on.ca/~jimmy/NIfTI

Comment only
30 Jul 2011 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

First, when you use 'save_nii.m', the file that you saved will always be in NIfTI instead of Analyze format.

Second, use 'load_untouch_nii' to load both original Analyze file and saved NIfTI file, and check what is the dimension size and data type of '.img' field.

Finally, I have tested to use 'load_nii.m' to load many Analyze and NIfTI files and then use 'save_nii.m' to save into NIfTI files. I did not find data size "increase remarkably". If it is possible, please upload your original Analyze data to somewhere that I can access, and email me the link (DO NOT USE EMAIL ATTACHMENT), so I can try to duplicate your problem.

By the way, I will not be available until Aug 2.

Comment only
05 Jul 2011 geotiffwrite Write a 2D or 3D array to a single or multi-band GeoTIFF file Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

If Model Type is "projected", you cannot use "bbox" variable directly, and you have to use "make_option.m" program to generate "option" variable.

Comment only
28 Jun 2011 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

First, both "load_nii" & "load_untouch_nii" support SPM NIfTI images. As a matter of fact, there is only one NIfTI standard, all NIfTI compatible software should comply with that standard.

Second, in order to duplicate the error, please upload that image onto anywhere that I can have read access. PLEASE DO NOT SEND BY EMAIL ATTACHMENT.

As you have noticed, NIfTI images can be in any spatial orientation, while "load_nii" can only have 48 orthogonal orientations. In that case, the program will prompt you to use "reslice_nii" to interpolate the image. Since you did not get the appropriate prompt, I am interested to take a look at the image that you are loading.

Please check my NIfTI web page for more details:

http://www.rotman-baycrest.on.ca/~jimmy/NIfTI

Comment only
20 May 2011 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Have you read:
http://nifti.nimh.nih.gov/nifti-1/documentation/nifti1fields as I mentioned?

As you can see, "origin" in NIfTI is expressed in sform or qform. When you use "load_nii", you should find it under: hdr.hist.originator(1:3)

Sometimes, with old ANALYZE image, the value is [0 0 0] which does not make sense, then you have no choice but use: hdr.dime.dim(2:4)/2.

Hope this helps.

Comment only
20 May 2011 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

The start positions for x, y, z are all 1. i.e. XYZvoxal=[1 1 1] is the place to start.

Please also check NIfTI header fields at:
http://nifti.nimh.nih.gov/nifti-1/documentation/nifti1fields

and let me know whether I understand your question correctly.

Comment only
13 Apr 2011 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Here's an example:
nii = load_nii('mydata.img',vol_id);
slice = nii.img(:,:,slice_id);
slice=round(63*(slice-min(slice(:)))/max(slice(:)))+1;
imwrite(slice,jet,'myslice.jpg');

Comment only
23 Feb 2011 Load BIOPAC ACQ (AcqKnowledge for PC) data Load BIOPAC's *.acq file (AcqKnowledge for Windows data format). Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Thijs, thanks to the open Python source code provided by Nathan Vack, this program can now load both ACQ4.0 and ACQ4.1. However, there is no documentation about ACQ 4 data format from BIOPAC.

Comment only
14 Feb 2011 Load BIOPAC ACQ (AcqKnowledge for PC) data Load BIOPAC's *.acq file (AcqKnowledge for Windows data format). Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

The latest release of file format by BIOPAC is up to AcqKnowledge 3.9:
http://www.biopac.com/ResearchNotes.asp?Aid=&ANid=82&Level=4
According to BIOPAC's AcqKnowledge 4 Software Guide:
http://www.biopac.com/file.asp?ManualID=56
It is now also able to save data into MAT-file binary format.

Comment only
22 Nov 2010 Load BIOPAC ACQ (AcqKnowledge for PC) data Load BIOPAC's *.acq file (AcqKnowledge for Windows data format). Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

There are 4 places that are using 'dec2hex' command. They are: dec2hex(hdr.color_major_grid), dec2hex(hdr.color_minor_grid), dec2hex(hdr.rgb_color), dec2hex(hdr.active_seg_color).

Those values in ACQ file header are not supposed to be negative.

Since none of those values will affect the channel data, you can replace them with ' ' if you believe your ACQ data have no other problem.

Comment only
13 Sep 2010 geotiffwrite Write a 2D or 3D array to a single or multi-band GeoTIFF file Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Hi David:

SRTM (Shuttle Radar Topography Mission) data are nothing but Big-Endian, 16-bit Signed Integer binary numbers with either in 1201x1201 (SRTM3) or in 3601x3601 (SRTM1) dimension. You can simply use the following script to do the job:

function srtm=load_srtm(fn)
fid=fopen(fn,'rb','ieee-be');
srtm.dat=fread(fid,inf,'*int16');
if length(srtm.dat)==1442401
srtm.dat=reshape(srtm.dat,[1201 1201]);
elseif length(srtm.dat)==12967201
srtm.dat=reshape(srtm.dat,[3601 3601]);
end
srtm.dat=rot90(srtm.dat);

Please let me know if you encounter any problem.

Jimmy

Comment only
17 Aug 2010 geotiffwrite Write a 2D or 3D array to a single or multi-band GeoTIFF file Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Hi David:

Thanks for you comments and rating.

Yes, you can use some of the fields contents returned by geotiffinfo to provide information for my option struct when you run the "make_option.m" program. However, please be careful, since my struct fields are DIRECTLY correspond to GeoTIFF Format Specification (like IDL software does); while struct fields from geotiffinfo in MATLAB software are NOT DIRECTLY correspond to GeoTIFF Format Specification. Here's a simple example: you can use geotiffinfo.TiePoints.WorldPoints for TiepointXYZ; but you cannot use geotiffinfo.TiePoints.ImagePoints for TiepointIJK.

I have just submitted 1-bit GeoTIFF support, so please come back in 2~3 days to see if they make my program available for you.

Jimmy

Comment only
03 Aug 2010 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

You may not notice the tolerance argument in "load_nii". By default, we allow no more than 10% of distortion. You can set it to 0, you will be prompted to use "reslice_nii" to interpolate the image.

If you just want to change negative value and NAN value to 0, you can simply use "load_untouch_nii" and "save_untouch_nii" pair to do the job.

Comment only
17 Jun 2010 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

First, you don't have to use "make_nii", which just creates a NIfTI struct for you based on your N-D matrix.

Second, make_nii supports float data. Type help make_nii for more details. Did you receive any error message?

Comment only
15 Jun 2010 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Hi Juan:

You can check "Question about overlay" category under:
http://www.rotman-baycrest.on.ca/~jimmy/NIfTI/FAQ.htm
There are several questions and answers in this topic.

You said that you have the x,y and z directions of each voxel. The x,y and z directions must be converted into the index regarding to the first voxel. Probably, you already have the brain region that represents the eigen image. Let's assume that you have it in a binary image called "brain_mask.nii", while the anatomical image is called "ana.nii". Here's what you can try:

1. Use "ana = load_nii(ana.nii)" to load the anatomical image, and make sure that variable "ana.img" is either in "single" or "double". If not, use step 2 to convert it.

2. To convert variable "ana.img" to "single", you need to use "make_nii" command: "ana = make_nii(single(ana.img), ana.hdr.dime.pixdim(2:4), ana.hdr.hist.originator(1:3))".

3. Use "mask = load_nii(brain_mask.nii)" to load the brain
mask image, and assign value and index to "opt" struct: "opt.setvalue.idx = find(mask.img); opt.setvalue.val = eigenvector;". You can see more detail to use "setvalue" by command: "help view_nii".

4. Add other values to "opt" struct: "opt.command = 'init'; opt.useinterp = 0;".

5. Plot eigen image with underlaid background by command: "view_nii(ana, opt);".

6. Don't click "interp on/off" menu. It doesn't work properly. If you would like to see the interpolated one, use: "opt.useinterp = 1; view_nii(ana, opt);" instead.

If you still have question, please feel free to ask me.

Jimmy

Comment only
04 Jun 2010 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Hi Preeti:

1) That's right, it does not support .avw format. So please save it in .hdr/.img or .nii format before you open them in MATLAB.

2) 300 slices should be okay on many new computers. If your computer cannot hold this much data in its memory, you may want to take 1 or several slices at a time to analyze. This feature was implemented on Jan. 6, 2010.

Comment only
14 Apr 2010 Load BIOPAC ACQ (AcqKnowledge for PC) data Load BIOPAC's *.acq file (AcqKnowledge for Windows data format). Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Hi Dino:

Theoretically, the changes that you suggested will increase the speed. However, it doesn't seem to speed up, after I tried several datasets.

Anyway, thank you very much for the feedback, and I will make the change in the next version.

Jimmy

Comment only
26 Jan 2010 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Hi Anne-Lene:

Don't worry. The following tips will give you some more help.

If you did not see difference after using "expend_nii_scan', it means that you only have 1 scan (1 volume) in your file. Since you said "...look at the nifti images separatley...", I thought you have several images (volumes or scans) in 1 file, and would like to treat them separately.

The first step you need to do is to load your image into MATLAB by "load_nii" command (Please look at "help load_nii" before using it).

Let's say you have an image "file1.nii" (or "file1.img/hdr"). By command:
nii = load_nii('file1.nii');
or
nii = load_nii('file1.img');
You can get a 3D matrix in "nii.img", and its header information in "nii.hdr".

You mentioned that you would like to change the image into another datatype. Here's how:

You can either change the header information directly (if you are familiar with the NIfTI header) then use "save_nii", or to use "make_nii" to create a new NIfTI structure (like nii).

For example:
datatype = 16; % change datatype to float32
nii2 = make_nii(nii.img, nii.hdr.dime.pixdim(2:4), nii.hdr.hist.originator(1:3), datatype);
save_nii(nii2, 'file2.nii'); % either to use nii ext
save_nii(nii2, 'file2.img'); % or to use img/hdr ext
By doing this, you changed it to Float32 data type, and saved it into "file2.nii" (or "file2.img/hdr").

If you have a MATLAB algorithm that you made by yourself as you mentioned, I think you will be more interested in the img matrix ("nii.img"). The "nii.hdr" is the header information to describe how "nii.img" is oriented, what is the voxel size, and originator, and many more.

Finally, I have to correct you that "make_nii" will not convert image to any extension. It only makes a NIfTI structure from N-D matrix and some other parameters (voxel size, originator, data type, etc.). Please double check the help, and make sure that you know how to use it.

If you have further question, please be more specific (e.g. make a point list), so I know how to help you.

Jimmy

Comment only
25 Jan 2010 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Hi Anne-Lene:

No questions are stupid.

Yes. You can use my tool to look at NIfTI images separately and also convert them to another datatype.

Since NIfTI supports both img/hdr and nii extensions, so my tool supports any of them.

Most help can be obtained by using help command. e.g. help make_nii.

There are several other resources that you can get help:
http://www.rotman-baycrest.on.ca/~jimmy/NIfTI
http://www.rotman-baycrest.on.ca/~jimmy/NIfTI/FAQ.htm
http://www.rotman-baycrest.on.ca/~jimmy/NIfTI/examples.txt

Command "expand_nii_scan" is used to break a multiple-scan NIfTI file into multiple single-scan NIfTI files, so you can look at them separately.

If you want to convert img data type, you can use "save_nii" after use "make_nii" command. If you are familiar with NIfTI structure, you can modify "hdr.dime" directly, and then use "save_nii" to save.

If you have further question, please make it more specific, so I can help you.

Jimmy

Comment only
06 Jan 2010 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Hi David:

I just got chance to look into this issue.

Since it is too complicated to modify "load_nii.m" to load specific slices of NIfTI and Analyze formats, I modified "load_untouch_nii.m" only. That means, you will take care of image orientation based on its header information, because "load_untouch_nii.m" does not apply any changes to the IMG matrix that is indicated in the HDR.

I hope this could still somehow help you to load large dataset.

Jimmy

Comment only
10 Nov 2009 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Hi Michael:

First, I am wondering how you could simply rename an .img file to a .nii file. NIfTI supports both extensions, but for .img extension, you need to save the header separately in .hdr file. So there is no way for people to just "... rename the .img file to .nii file ..." like you said.

Second, I looked into Francesca's data, and the size of the image data does not match the size that is indicated in the header. For such a file, I cannot image any software can process it.

I am glad to take a look at your samples. Would you please upload them onto your server, and post the link here?

Thanks,
Jimmy

Comment only
09 Nov 2009 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Hi Wei:

Thanks for the rate.

When you use "load_untouch_nii.m", it just load the img and hdr, but does not apply any changes (e.g. scl_slope, affine matrix, etc) indicated in the header. Therefore, I always suggest people to use "load_nii.m" in most cases. Please check the description of "load_untouch_nii.m" & "load_nii.m" on http://www.rotman-baycrest.on.ca/~jimmy/NIfTI.

You are right, the unexpected value was caused by the "scl_slope" parameter, which is properly applied when you use "load_nii.m". However, I am not sure whether you have noticed that this is a radiological image, i.e. Right on LHS and Left on RHS. Here, L/RHS means Left/RightHandSide.

When you use "load_nii.m", it will do all the proper flipping and rotation according to the affine matrix in the header, and the img will always be in RAS orientation (i.e. x: L->R, y: P->A, z: I->S). In your particular case, instead of use [32 32 23], you should use [33 32 23], since x axis is flipped, i.e. new_x = max_x(64) - old_x(32) + 1 = 33.

Other software may choose to do so with proper labeling around Axial / Sagittal / Coronal view, e.g. FSL does so.

Please feel free to let me know if you have further question.

Jimmy

Comment only
06 Nov 2009 Tools for NIfTI and ANALYZE image Load, save, make, reslice, view (and edit) both NIfTI and ANALYZE data on any platform Author: Jimmy Shen

Jimmy Shen (view profile)

Jimmy Shen

Jimmy Shen (view profile)

Hi Francesca:

First, thank you very much for the rating, and I really appreciate it.

It seems that "lCC_19850624TRTN_2x2x2_b1000_a_fa.nii'" is corrupted. Have you tried to open it successfully under MRIcro? If so, please upload this file and let me take a look at it?

In addition, from the error message that you posted, it seems that you are using a very old version of my tools. I noticed this by the line number showing the error. However, I still believe that the error is caused by the corrupted image.

Please let me know,
Jimmy

Comment only

Contact us