# Regarding import

**URL:** <https://discourse.slicer.org/t/regarding-import/3962>\
**Category:** Support\
**Created:** [August 31, 2018, 7:38pm UTC](https://discourse.slicer.org/t/regarding-import/3962 "2018-08-31T19:38:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomas](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@tomas](https://discourse.slicer.org/u/tomas)\
**Post date:** [August 31, 2018, 7:38pm UTC](https://discourse.slicer.org/t/regarding-import/3962/1 "2018-08-31T19:38:25Z")

</div>

Operating system: windows 10 64 bit  
Slicer version: 4.9 nightly  
Expected behavior: import .mat file  
Actual behavior: doesn’t import

Hi folks,

I have some Ultrasound volume data (video data) saved as .mat files with voxel data type uint8 and respected position in other .mat file; what is the best way to import them into 3D slicer for processing? I convert video data (datavideo\_ultrasound) to Dicom images, but I could not import position info to DICOM images. Could you please suggest me some solutions?

Thanks.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 31, 2018, 7:47pm UTC](https://discourse.slicer.org/t/regarding-import/3962/2 "2018-08-31T19:47:23Z")

</div>

You can write the volume into a NRRD file using [nrrdwrite.m](https://github.com/PerkLab/SlicerMatlabBridge/tree/master/MatlabCommander/commandserver) and load that very easily into Slicer (and many other medical image computing software).

---

<div class="post-metadata">

**Author:** ![tomas](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@tomas](https://discourse.slicer.org/u/tomas)\
**Post date:** [September 1, 2018, 10:45pm UTC](https://discourse.slicer.org/t/regarding-import/3962/3 "2018-09-01T22:45:13Z")

</div>

It is working properly for one 2d image to load in Slicer. But for 3d image it is not working. I have one ultrasound video (.mat) file. where I generated 278 2d images using the for loop below. therefore I used ‘cat’ for generating 3d image. Then I used nrrdwrite to get nrrd file. but this 3d nrrd is showing nothing in slicer. I have positions of each 2d image, which is Commented in the code. It might work, if I can use position of 2d images for generating nrrd file. Is it possible to use the positions in nrrdwrite?

Thank you very much.

clc  
for i=1:278  
eval(sprintf(‘A%d = datavideo(:,:,1,i);’, i));  
% eval(sprintf(‘position%d = new\_psonda(:,:,i);’, i));  
end

v1=cat(3,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10);  
img.pixelData = v1;  
nrrdwrite(‘v1’, img);

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 1, 2018, 11:20pm UTC](https://discourse.slicer.org/t/regarding-import/3962/4 "2018-09-01T23:20:10Z")

</div>

Is this a color image?

Please copy here the complete error message.

---

<div class="post-metadata">

**Author:** ![tomas](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@tomas](https://discourse.slicer.org/u/tomas)\
**Post date:** [September 2, 2018, 1:33am UTC](https://discourse.slicer.org/t/regarding-import/3962/5 "2018-09-02T01:33:14Z")

</div>

No, it is grayscale image.

I find the error, I didn’t put .nrrd in the file name. Now it is working fine. Thank you very much.

nrrdwrite(‘v1.nrrd’, img);
