How to transfer Nifti file into .mat Matlab file? - matlab

I have a Nifti file, the size of which is 62*62*38. How can I transfer the Nifti file to .mat Matlab file?

Most medical imaging data can be manipulated effectively using some kind of toolbox, such as SPM. However, if you need to gain access to the raw matrix I've always used NIfTI tools from the Mathworks file exchange site (here).
There are two functions that are relevant here: load_nii and load_untouched_nii. The first function load_nii takes care of situations where the header in the NiFTI contains transformations that haven't been applied to the underlying data matrix. If you know that no such transformations exist, you can use load_untouched_nii to avoid the reslicing being done. Both functions return a structure, and the data matrix is located in the img field of the returned structure.

This can read NIFTI as well as many other medical image file types into MATLAB arrays, which you can then save as .mat files.

FreeSurfer has a MATLAB function called "MRIread". It can read NIFTI (.nii, .nii.gz) files into a MATLAB structure, which can then be saved to a MAT file if so desired.

Related

Can .cnt file be converted to spectrogram images in matlab? if yes then how to do it?

I have an EEG signal with .cnt and .fdt files. I have to obtain images to use it as input to a cnn. Is it possible to convert the file to images? Someone please help me with this. If possible then specify how to do it.
You should download EEG tollbox such as EEGlab or FieldTrip. I prefer fieldtrip because it is script based while EEGlab is more about GUI. Here you can see fieldtrip's function ft_read_header that can deal with your files, and here is a basic script to read cnt files with fieldtrip functions

How to I populate .mat database in matlab

How do I train images and make a .mat file?
I am trying the following simple matlab program :
http://in.mathworks.com/matlabcentral/fileexchange/22030-image-retrieval-query-by-example-demo
Documentation
https://ece.uwaterloo.ca/~nnikvand/Coderep/imQuery/documentation.html
Now, this zip package already includes a .mat file which has histograms of all the sample images provided for querying.I want to query over my own sample-set of images.
I figured out that I need that getimagehist function to calculate the histogram and populate a database of my images in .mat format. but how exactly do i do it? I am a newbie in matlab that's why i have no idea. A little guidance/help will be greatly appreciated.
In Matlab, the .mat format is used for saving Matlab workspaces. You can create .mat files with
save(filename,variables)
It is documented here: http://se.mathworks.com/help/matlab/ref/save.html
If you need help in creating the histograms from images, check imhist: http://se.mathworks.com/help/images/ref/imhist.html
As an example of saving a histogram in .mat file
myHistogram = imhist(image);
save('myMatFile', 'myHistogram');

Training neural network in matlab

I have multiple .mat files. In each file I saved multiple features of an image (like intensity, hue etc). I want to train a neural network to categorize these images. I already have excel file containing the output categories of each image.
Now question is that I have to load all the .mat files and fed it as input to neural network or I have to take only single file each time and its corresponding output category. Can anyone please clarify this?
Also how can I give multiple .mat files containing multiple variables as input to a neural network?
maybe is the best to load all .mat files which contain parameters you want to use for training of neural network and put all your input parameters into one variable, and than to use that variable as the input for neural network.

extracting an output matrix from matlab

I am working on a small iris recognition system using matlab, my matlab code after several steps and algorithms gives me a 9600 bit matrix as an output, and I was wondering how can I take this matrix to process it using a Windows Forms application using C#?
There are some standard formats that you can work with them both in MATLAB and C#.
For example, you can use csvwrite function in MATLAB to save it as a comma-separated value file. The in C# there are standard ways to read a csv file. Here it is discussed how to read a CSV file in C#.
Another option is to save in a .txt file and read it in C#. HDF5 files are another type that are supported with some libraries in both (see here). You can even save your file as a regular .mat file and load it in C# using a specific API (discussed here)

How to extract the continuation data from the MatCont continuation package on MATLAB?

I have been using MatCont for generating continuation figures for my model ODEs. Dissatisfied with the quality of figures on MATLAB, I would like to to use another program (e.g., Gnuplot) for plotting this continuation data.
In this regard, I would like to know whether there is a way of writing the continuation data to a CSV file or similar? I tried extracting data from .fig figure files that were created using MATLAB but it did not work.