-
-
Save ofgulban/14cda2738620569701859086527bfcca to your computer and use it in GitHub Desktop.
| % Convert Brainvoyager VMP files to nii using neuroelf. | |
| % Select VMR | |
| [vmr_fileName, vmr_pathName] = uigetfile('.vmr'); | |
| vmr = xff(fullfile(vmr_pathName, vmr_fileName)); | |
| % Select VMP | |
| [vmp_fileName, vmp_pathName] = uigetfile('.vmp'); | |
| vmp = xff(fullfile(vmp_pathName, vmp_fileName)); | |
| map_index = 1; % change this is you have multiple maps in one vmp file | |
| % Resample VMP to fit in VMR | |
| map_data = vmp.Map(map_index).VMPData; | |
| nx = vmp.XEnd - vmp.XStart; | |
| ny = vmp.YEnd - vmp.YStart; | |
| nz = vmp.ZEnd - vmp.ZStart; | |
| [x, y, z]= ndgrid(linspace(1, size(map_data, 1), nx), ... | |
| linspace(1, size(map_data, 2), ny), ... | |
| linspace(1, size(map_data, 3), nz)); | |
| map_data = interp3(map_data, x, y, z, 'bicubic'); | |
| % Use vmr to host a vmp map | |
| vmr.VMRData = vmr.VMRData*0; | |
| vmr.VMRData(vmp.XStart:vmp.XEnd-1, ... | |
| vmp.YStart:vmp.YEnd-1, ... | |
| vmp.ZStart:vmp.ZEnd-1) = map_data; | |
| % Save | |
| vmr.ExportNifti(fullfile(vmp_pathName, [vmp_fileName(1:end-4),'.nii']) ); | |
| disp('Done.') |
Hi @arnaublanco , I would guess that the following might work, though there can be problems depending on what you want to do next with those niftis:
[vtc_fileName, vtc_pathName] = uigetfile('.vtc');
vtc = xff(fullfile(vtc_pathName, vtc_fileName));
vtc.ExportNifti(fullfile(vtc_pathName, [vtc_fileName(1:end-4), '.nii']) );
I currently do not have access to matlab, so I cannot test it with neuroelf.
The code seems to convert my VTC file into NifTi with no problem. Thanks! What problem could I run into?
And by the way, could I use this code to also convert MTC files into NifTi?
Thanks a lot,
Arnau.
If it works with no immediately visible problems, great. I think there is no need to list the potential problems, as they can be very different based on what needs to be accomplished.
MTC files are very different compared to VTC as MTC files are built to work with surfaces while VTC are built to work with volume images. So you cannot convert MTC files them into nifti volume images.
Okay! Perfect! Thanks a lot!
Hello @ofgulban,
Sorry to bother you again. Would it be possible to convert a MTC file into the GifTi format of NeuroElf?
Thanks in advance,
Arnau.
Hi @arnaublanco , I think converting MTC to Gifti is possible (considering the data structures) but I have never did this in neuroelf. In general I did not use MTC much in the past.
Hello @ofgulban,
Do you have any script to convert VTC files to the NifTi format (.nii)?
Thanks a lot!
Arnau.