# Reading the .obj (+.mtl) brain atlas and exporting as .nii

**URL:** <https://discourse.slicer.org/t/reading-the-obj-mtl-brain-atlas-and-exporting-as-nii/10161>\
**Category:** Support\
**Tags:** file-export, 3d-model, file-import\
**Created:** [February 7, 2020, 4:32pm UTC](https://discourse.slicer.org/t/reading-the-obj-mtl-brain-atlas-and-exporting-as-nii/10161 "2020-02-07T16:32:10Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![BegginerUser](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@BegginerUser](https://discourse.slicer.org/u/BegginerUser)\
**Post date:** [February 7, 2020, 4:32pm UTC](https://discourse.slicer.org/t/reading-the-obj-mtl-brain-atlas-and-exporting-as-nii/10161/1 "2020-02-07T16:32:11Z")

</div>

Hello,

I decided to use a Slicer in order to make a brain atlas conversion.  
I exported a brain atlas which includes different brain areas with Neurolucida as .obj + .mtl file.  
I need to convert that atlas into nifti (.nii) format in order to read it with an MRI imaging called NORA.  
Could you please help me how to do it?  
What I tried is:

1. importing .obj as a model
2. importing .mtl as a volume  
Problem: I do not see different brain areas, the whole brain is gray  
Problem: I do not see a .nii format when I click the export button.

Hope somebody could navigate me through the exporting process.  
Wish you all the best,  
Lara

---

<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:** [February 7, 2020, 4:51pm UTC](https://discourse.slicer.org/t/reading-the-obj-mtl-brain-atlas-and-exporting-as-nii/10161/2 "2020-02-07T16:51:55Z")

</div>

Is each brain area stored with a different material? Can you share a sample data set?

Currently, a single obj file is always loaded as a single segment, so you would need to split it into separate mesh files before you export it or write a short Python script in Slicer that splits the mesh based on material ID.

---

<div class="post-metadata">

**Author:** ![BegginerUser](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@BegginerUser](https://discourse.slicer.org/u/BegginerUser)\
**Post date:** [February 10, 2020, 5:04pm UTC](https://discourse.slicer.org/t/reading-the-obj-mtl-brain-atlas-and-exporting-as-nii/10161/3 "2020-02-10T17:04:25Z")

</div>

Dear Andras,

Thank you for the answer! I saved the whole model as a single .obj accompanied with a single material. I will follow your advice on saving each segment separately! Thanks for the explanation.

Lara

---

<div class="post-metadata">

**Author:** ![BegginerUser](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@BegginerUser](https://discourse.slicer.org/u/BegginerUser)\
**Post date:** [February 15, 2020, 2:16pm UTC](https://discourse.slicer.org/t/reading-the-obj-mtl-brain-atlas-and-exporting-as-nii/10161/4 "2020-02-15T14:16:53Z")

</div>

Hello Andras,

Thank you for the previous answer. I have followed your recommendation and have uploaded two brain regions as separated .obj files.

I visualized them as a solid and as a mesh

 ![test01_surface](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/a/fa414e510c4f51a6fe59dd58830725b3e449719f.png)

I need to convert both objects into the volume.  
I cannot save it as a nifti (.nii) if I do not convert it to a volume.

Could you please advice me on how to make a conversion from a current model to a volume?

Thanks again for your help Andras!  
You are the best.  
Lara

---

<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:** [February 15, 2020, 6:34pm UTC](https://discourse.slicer.org/t/reading-the-obj-mtl-brain-atlas-and-exporting-as-nii/10161/5 "2020-02-15T18:34:19Z")

</div>

The most robust way to convert a mesh to an image is to import it into segmentation and export it to a labelmap image. You can find these conversion options in data module if you right-click the data node.

---

<div class="post-metadata">

**Author:** ![BegginerUser](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@BegginerUser](https://discourse.slicer.org/u/BegginerUser)\
**Post date:** [February 16, 2020, 2:21pm UTC](https://discourse.slicer.org/t/reading-the-obj-mtl-brain-atlas-and-exporting-as-nii/10161/6 "2020-02-16T14:21:35Z")

</div>

Dear Andras,  
I got it!

I exported each segment as separated nifti, however I lost parameters of orientation and size in the nifti header.  
I believe I lost the parameters while importing the .obj into Slicer. Obj file is accompanied with .mtl, but I could not import the .mtl into as a scalar overlay.

Could you please help me to re-define the size and orientation?

Best regards,  
Lara

---

<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:** [February 16, 2020, 3:03pm UTC](https://discourse.slicer.org/t/reading-the-obj-mtl-brain-atlas-and-exporting-as-nii/10161/7 "2020-02-16T15:03:43Z")

</div>

Physical size and orientation of the labelmaps are correct. Probably you only checked the voxel coordinates. If you want the labelmap in a specific physical geometry (origin, spacing, axis directions, extents) then export using Segmentations module and specify a reference volume.

---

<div class="post-metadata">

**Author:** ![BegginerUser](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@BegginerUser](https://discourse.slicer.org/u/BegginerUser)\
**Post date:** [February 18, 2020, 12:14pm UTC](https://discourse.slicer.org/t/reading-the-obj-mtl-brain-atlas-and-exporting-as-nii/10161/8 "2020-02-18T12:14:35Z")

</div>

I found where the problem was - the exported property of Image Spacing was defined in wrong units thus it was read as 2.4 instead of 0.024 in a slicer (Model was exported with Neurolucida in case other user finds the same obstacle).

Finally my histology image (image I worked with in Slicer) was the same size as the MRI image.  
Now I ran into another trouble - my histology image has more z slices than the MRI so I cannot superimpose them. Is there a way to down-sample the z direction of the nii image in Slicer?

Thank you much for your help Andras!

---

<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:** [February 18, 2020, 1:25pm UTC](https://discourse.slicer.org/t/reading-the-obj-mtl-brain-atlas-and-exporting-as-nii/10161/9 "2020-02-18T13:25:19Z")

</div>

> [@BegginerUser](#):
>
> my histology image has more z slices than the MRI so I cannot superimpose them

Superimposing histology and MRI in Slicer should be no problem, regardless of the size or resolution of the images, as both images are displayed in the physical coordinate system. Do you mean that you would like to superimpose the images in some third-party software that ignores physical coordinate system information?

---

<div class="post-metadata">

**Author:** ![BegginerUser](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@BegginerUser](https://discourse.slicer.org/u/BegginerUser)\
**Post date:** [March 1, 2020, 12:26pm UTC](https://discourse.slicer.org/t/reading-the-obj-mtl-brain-atlas-and-exporting-as-nii/10161/10 "2020-03-01T12:26:58Z")

</div>

Dear Andras,

Thank you for your help again!  
Yes, I used a third party software for alignment after exporting the model from Slicer. The problem is in the third-party software I used. I tried the same in slicer and it worked perfectly. Thank you for leading me through the process. I am very grateful.

Wish you a wonderful day,  
Lara
