How to merge 3D .RAW files into ImageJ without loosing their original locations

imagej1
#1

Hi,

I am trying to import 3d *.RAW files into ImageJ, merge them and export them to one single binary file format (the ultimate goal is to a single .bin file format).

Each raw file corresponds to a voxelized object ( exported from BINVOX) to build 3D modeling. Each object has its own coordinates; it is essential to preserve its coordinate to construct the model accurately.

Please, help me!

Regards
R.M

0 Likes

#2

Hi @Rasha_Makkia,

Welcome to the forum.

I have some questions that will make it easier to get you useful help:

  • What do you know about the “raw” file format? i.e. bit-depth, size, etc?
  • Is this the program you used to export your meshes?
    • If so, binvox says it can write to the nrrd file format, which imagej (Fiji) can read from.
  • What do you mean by “merge”

John

0 Likes

#3

Hello John,

Thanks for your quick replay. To answer your questions:

I am developing a voxelized computational human phantom. I have 3d .raw files for different organs generated by BINVOX software after being exported from Rhinoceros in .wrl files. The file sizes depend on the organ size and voxel resolution that I specified through BINVOX.

The goal is to recombine all the voxelized organ files together using ImageJ in one single binary file (.bin) keeping the same organ locations and IDs.

As far as I know BINVOX can export only in either schematic file or raw file.

In term of the previous post, It is essentially the same.

Regards
R.M

1 Like

#4

Thanks @Rasha_Makkia thats helpful, but I’m not familiar with BINVOX, and havn’t seen it come up on this forum before, so you’ll have to educate us (me).

Got it, but let’s start at the beginning, you want to use imageJ. Have you been able to import your raw files into imageJ?

File > Import > Raw... is helpful here.
Once you get an image open, then it might help if you post a screenshot of your image(s) here to help explain your goal.

John

0 Likes

#5

I will describe it in two ways:

  1. Yes, I was able to import the first raw organ file to ImageJ nicely. Next, I need to add another raw organ file hoping to present both of these organs in their own locations following this step:

To upload the first raw file (5.raw):
image
To add the second raw file (1.raw) folliwing the same approch:
image
image
image
image

Using this method, l lost the original organ locations.

  1. In this website a similar approach:

http://www.irpabuenosaires2015.org/Archivos/archivos/Sesiones%20Tecnicas/ST%20Dosimetria%20Externa/MONTEIRO.pdf

Please, let me know,

R.M

1 Like

#6

Hi @Rasha_Makkia,

Can you share some detail on how you used BINVOX to generate those masks?
Specifically I’m curious if one of these is the case:

  1. You tell BINVOX what spatial field of view you want for the output volume
  2. BINVOX automatically finds the field of view and tells you what it is
  3. BINVOX automatically finds the field of view but doesn’t tell you

Since it writes the results to a raw format, offset information is obviously lost, as you have found. If either (1) or (2) is true, then we’re in good shape, but if (3) is the case, then it will be much harder.

If you know what the offset of each image is, then we can put together a script that does what you need. By “offset” I mean the coordinate in the original space does the origin in each binary image correspond to?)

John

0 Likes

#7

Hello John,

I have the bounding box for each raw file created and I choose the voxel resolution in Binvox.

I think the offset is stored in the raw file itself. Would you like me to share couple of these files with you to investigate this further?

Regards,

R.M

0 Likes

#8

That would be helpful.
And if you know how / if to get the offset from the file, that will help too

0 Likes

#9

I will be sending two files with you with their bounding box ( the object spatial coordinates).

Thank you!

0 Likes

#10

Files.rar (4.5 MB)

The attached files are:

5 WRL files named (1.wrl, 2.wrl, 3.wrl, 4.wrl, 5.wrl) ----> Origninal files imported from Rhincoers
5 RAW files named ( 1.raw, 2.raw, 3.raw, 4.raw, 5.raw) ------> Voxelized files extracted from Binvox
5 NRRD files named ( 1.nrrd, 2.nrrd, 3.nrrd, 4.nrrd, 5.nrrd) ------> Voxelized files extracted from Binvox [If there is alternative way to import them to ImageJ (Fiji) can read them]

I also include their voxel resolutions and bounding boxes (From their original position To their final position in 3D coordinates).

I hope this would help to merge the 5 raw files in one single binary file (.bin).
Please, let me know if anything else is needed,

Thanks!
R.M

0 Likes

#11

Hi @Rasha_Makkia,

I had a busy week, and havn’t had much time to look into this.
One question, can you confirm that I’m understanding the information in the spreadsheet: Bounding Box Info.

Is Voxel Resolution column the size of the image?
i.e. I interpret 120x120x120 to mean that the image is a cube with 120 voxels on a side

Are the three columns in Bounding Box: From the in physical units of the top left (0,0,0) voxel? And are u, v, and i the first, second and third dimensions, respectively?

Same question for Bounding Box: To.
I interpret those values to be the location in physical units of the “last” pixel, e.g. the pixel with indices 119,119,119 (for the example above).

Is that correct? and if not, could you please clarify?

John

0 Likes

#12

Hello John,

For each file I send, there is a bounding box belongs to it. the bounding box represents the dimension of each 3d object in space. More info: https://developer.rhino3d.com/api/rhinoscript/geometry_methods/boundingbox.htm

The 120x120x120 means the image is a cube with 120 voxels for each side. (Yes, you described it correctly).

Please, let me know if you have any questions. I will be glad to help, as well.

Regards,
Rasha

0 Likes

#13

Hello John,

I would like to follow up with you regarding to combine the raw files in one single raw file. Please, let me know.

Regards
R.M

0 Likes

#14

Hi @Rasha_Makkia,

The script below should be capable of doing what you want

Information on running scripts here.

The script takes the image you specify to Add and puts the value Value in wherever that image is greater than 128 (your images take values of 0 and 255). You can give the min and max for each mask as text, with numbers separated by spaces.

The image below is what I get - it looks weird to me though. Are you sure that I’m interpreting the x- y- and z- values correctly?

While this is unlikely to be correct, maybe it will get you most of the way there.

John

0 Likes

#15

Hello John,

I will check this and get back to you.

Thank you

R.M

0 Likes