# Show ROI boxes - if loading from .obj file then all boxes appear in yellow color

**URL:** <https://discourse.slicer.org/t/show-roi-boxes-if-loading-from-obj-file-then-all-boxes-appear-in-yellow-color/34341>\
**Category:** Support\
**Tags:** python\
**Created:** [February 15, 2024, 12:24pm UTC](https://discourse.slicer.org/t/show-roi-boxes-if-loading-from-obj-file-then-all-boxes-appear-in-yellow-color/34341 "2024-02-15T12:24:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayadav01](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@ayadav01](https://discourse.slicer.org/u/ayadav01)\
**Post date:** [February 15, 2024, 12:24pm UTC](https://discourse.slicer.org/t/show-roi-boxes-if-loading-from-obj-file-then-all-boxes-appear-in-yellow-color/34341/1 "2024-02-15T12:24:07Z")

</div>

Hi, I have saved bounding box coordinates in an .obj file and i am able to load it in slicer and visualize it correctly. I also have a .mtl file that contains the box color information; however, every time i load up the .obj file, it only shows up in yellow color box. I am not sure if i am specifying the color parameter in the .mtl file correctly. This is what i have in the 6b.nii.obj file:

```auto
mtllib 6b.nii.mtl

v 240.0158052444458 92.24226522445679 -170.0
v 240.0158052444458 78.96100568771362 -170.0
v 226.73454570770264 78.96100568771362 -170.0
v 226.73454570770264 92.24226522445679 -170.0
v 240.0158052444458 92.24226522445679 -190.0
v 240.0158052444458 78.96100568771362 -190.0
v 226.73454570770264 78.96100568771362 -190.0
v 226.73454570770264 92.24226522445679 -190.0

usemtl bbox
f 1 2 3 4
f 5 8 7 6
f 1 5 6 2
f 2 6 7 3
f 3 7 8 4
f 5 1 4 8

```

This is what i have in the 6b.nii.mtl file

```auto
newmtl bbox
Ka 0 0 0
Kd 0.0 1.0 0.0
Ks 0 0 0
Ns 3
Tr 1
illum 3

```

Any help is greatly appreciated. Also, is there a way to specify line-width in the .mtl file ? Please let me know. Thank you!

---

<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, 2024, 12:29pm UTC](https://discourse.slicer.org/t/show-roi-boxes-if-loading-from-obj-file-then-all-boxes-appear-in-yellow-color/34341/2 "2024-02-15T12:29:39Z")

</div>

Slicer only loads the geometry from OBJ files. Material files are ignored.

It would not be too hard to implement an importer that creates multiple models (one per material), color and opacity set for each based on the material. Would this be sufficient?

If you just want to load a single colored mesh then your can use ply or vtk file format instead.

What is your overall goal? What would you like to do with the mesh in Slicer?

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [February 15, 2024, 4:48pm UTC](https://discourse.slicer.org/t/show-roi-boxes-if-loading-from-obj-file-then-all-boxes-appear-in-yellow-color/34341/3 "2024-02-15T16:48:32Z")

</div>

In slicermorph, you can import an OBJ file with materials. We haven’t tested extensively but seem to work for the photogrammetry models we have built for a project.

@ayadav01  
Install slicermorph extension, restart slicer, drag and drop your model, and in the dialog box, choose **OBJ Textured Model** as the Description (as opposed to default Model).

See if that helps…

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/0/5057ddc58011a831b6a0958169492db1eab12363.png)

---

<div class="post-metadata">

**Author:** ![ayadav01](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@ayadav01](https://discourse.slicer.org/u/ayadav01)\
**Post date:** [February 15, 2024, 8:55pm UTC](https://discourse.slicer.org/t/show-roi-boxes-if-loading-from-obj-file-then-all-boxes-appear-in-yellow-color/34341/4 "2024-02-15T20:55:40Z")

</div>

Thanks Andras. I have a bunch of .obj files that correspond to different type of detections in a CT scans, and i would like to visualize those detected boxes in different colors (i.e., each .obj should display with a unique color). I am not sure how to convert the coordinates in the .obj to a .vtk file and how to specify the color or line width parameter in that file.

---

<div class="post-metadata">

**Author:** ![ayadav01](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@ayadav01](https://discourse.slicer.org/u/ayadav01)\
**Post date:** [February 15, 2024, 8:58pm UTC](https://discourse.slicer.org/t/show-roi-boxes-if-loading-from-obj-file-then-all-boxes-appear-in-yellow-color/34341/5 "2024-02-15T20:58:38Z")

</div>

I am working on a plugin that is specific to slicer so ideally i want it to be able to work with slicer.

---

<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, 2024, 10:44pm UTC](https://discourse.slicer.org/t/show-roi-boxes-if-loading-from-obj-file-then-all-boxes-appear-in-yellow-color/34341/6 "2024-02-15T22:44:52Z")

</div>

I would recommend to use “Markups ROI” nodes for showing ROI boxes in Slicer. You can create a `myregions.mrk.json` and add any number of ROI boxes to it. For example, file content for two ROI boxes:

```json
{
    "@schema": "https://raw.githubusercontent.com/slicer/slicer/master/Modules/Loadable/Markups/Resources/Schema/markups-schema-v1.0.3.json#",
    "markups": [
        {
            "name": "My first region",
            "type": "ROI", "roiType": "Box", "coordinateSystem": "LPS", "coordinateUnits": "mm",
            "controlPoints": [{"position": [5.9, -12.3, -10.2], "locked": true}],
            "orientation": [-1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0],
            "size": [39.3, 32.4, 32.4],
            "display": {"selectedColor": [0.4, 1.0, 1.0], "handlesInteractive": false}
        },
        {
            "name": "My second region",
            "type": "ROI", "roiType": "Box", "coordinateSystem": "LPS", "coordinateUnits": "mm",
            "controlPoints": [{"position": [45.9, -102.3, -10.2], "locked": true}],
            "orientation": [-1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0],
            "size": [20.0, 30.5, 44.4],
            "display": {"selectedColor": [1.0, 0.0, 1.0], "handlesInteractive": false}
        }
     ]
}

```

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/5/15196c8564adc3e5f2f647795d3f9d3e3bc6a2ef.jpeg)

---

<div class="post-metadata">

**Author:** ![ayadav01](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@ayadav01](https://discourse.slicer.org/u/ayadav01)\
**Post date:** [February 16, 2024, 2:00am UTC](https://discourse.slicer.org/t/show-roi-boxes-if-loading-from-obj-file-then-all-boxes-appear-in-yellow-color/34341/7 "2024-02-16T02:00:35Z")

</div>

Thanks Andras. This is exactly what i was looking for. Is there a way to change the opacity of the box in the axial view or line-width of the box by any chance ?

---

<div class="post-metadata">

**Author:** ![ayadav01](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@ayadav01](https://discourse.slicer.org/u/ayadav01)\
**Post date:** [February 16, 2024, 2:02am UTC](https://discourse.slicer.org/t/show-roi-boxes-if-loading-from-obj-file-then-all-boxes-appear-in-yellow-color/34341/8 "2024-02-16T02:02:31Z")

</div>

Actually nevermind, i see the opacity key in the template from the github link.

---

<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, 2024, 2:12am UTC](https://discourse.slicer.org/t/show-roi-boxes-if-loading-from-obj-file-then-all-boxes-appear-in-yellow-color/34341/9 "2024-02-16T02:12:48Z")

</div>

You can see most options if you save a markup ROI to file and have a look at the file.
