xcist / main

simulation and reconstruction package
BSD 3-Clause "New" or "Revised" License
47 stars 23 forks source link

Support material fraction in nrb format #104

Open purepani opened 1 week ago

purepani commented 1 week ago

It looks like there is a new xcat nrb format that the current version of gecatsim is unable to parse. From what I can tell, now xcat can simulate one surface being multiple different materials with different fractions whereas the current parsing only lets you parse 1 material per surface(assuming im reading the code correctly). Relevant parsing code: https://github.com/xcist/main/blob/74309d1b216eff0073d9602c9ce6c1ac7ebd1a2c/gecatsim/clib_build/src/nCAT_main.c#L3332-L3338

Relevant data from nrb files generated from xcat.

musc212
1
1.0
20 :M
33 :N
U Knot Vector
0.000000
0.000000
0.000000
0.000000
...
lrib4
0,4
0.500000,0.500000
45 :M
23 :N
U Knot Vector
0.000000
0.000000
0.000000
0.000000
0.050000
0.100000
0.150000

I didn't want to try to incorporate this into the model since I'm not fully familiar with how to do so, and it would probably require a new projector as well(which I'm not certain the best way to implement it), so i figured an issue is best here.

MingyeWu commented 1 week ago

Hi purepani,

The combination of multiple materials with different fractions can be defined as one material. Then, you need to hack Phantom_NCAT.py --> set_material, and add that user-defined material. Last, in the XCAT phantom definition, you set the material index.

Maybe we can add a cfg parameter to allow the user to add new materials.

purepani commented 1 week ago

Would it be possible to have the projector take into account the material fractions so that new materials wouldn't need to be added and the phantom definition wouldn't need to be edited?

MingyeWu commented 1 week ago

Would it be possible to have the projector take into account the material fractions so that new materials wouldn't need to be added and the phantom definition wouldn't need to be edited?

It requires updating the projector C source code, which is a bit larger effort than changing the python phantom code.

purepani commented 1 week ago

I wouldn't mind doing that, especially if this is something you want upstream as well

MingyeWu commented 1 week ago

That would be great! The C code is nCAT_main.c. You'll need to change how it reads the XCAT data file, and how it initializes the Mu table for the objects.

purepani commented 1 week ago

I found an "output old ct format" in the xcat parameter files which creates a file format that the program is expecting. How would you want to manage these 2 formats? Automatically detect which format it is? or just have 2 separate functions for each version? or something else?