xcist / main

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

Reconstruction output #101

Closed purepani closed 4 weeks ago

purepani commented 1 month ago

I am attempting to use this library for reconstruction and need a dicom output, so I was intending to use the direct output from the reconstruction and use pydicom. However, looking here, it looks like there is no direct output for the volume(cfg is returned and imageVolume3D is just discarded. I can just write and immediately read it to /tmp, but, especially for large files, it might be better to have a direct output if it's possible to get one.

zhangjy-ge commented 1 month ago

it looks like there is no direct output for the volume(cfg is returned and imageVolume3D is just discarded.

Actually in this line https://github.com/xcist/main/blob/a361eecea003249b96ec41aa7f08c3dfa4aa7b34/gecatsim/reconstruction/pyfiles/recon.py#L20, you can see that imageVolume3D is saved, and you just need to set cfg.recon.saveImageVolume to true. The saved volume data will be something like xxx_512x512x4.raw (you may read this page https://github.com/xcist/example/tree/main/AAPM_datachallenge/proj_and_recon#usage for the format of this raw file, and you can also read it by calling the xc.rawread function), can then be postprocessed by pydicom or whatever.

purepani commented 1 month ago

Yeah that's what I meant by saving and reading it back in. While it's not too hard to do that, it would have less overhead with writing to a filesystem and be a bit easier to have the direct output of the object from the function(in the form of , for example, a numpy array, perhaps wrapped with some metadata).

zhangjy-ge commented 1 month ago

Unfortunately we don't have the plan to save the data in another format (like numpy array) because raw format is usually better for visualization, and we don't want to have redundant functions/data. You're welcome (and it should also be easy) to implement the function by yourself, though.

BTW, raw format is also the direct output of the object, and reading it with python is also very intuitive https://github.com/xcist/main/blob/a361eecea003249b96ec41aa7f08c3dfa4aa7b34/gecatsim/pyfiles/CommonTools.py#L362

purepani commented 1 month ago

Just for clarity, this is basically all I'm asking for: https://github.com/xcist/main/pull/102. It's certainly not hard to manually do this; this is just how I would imagine interacting programmatically with the library would be like. No problem if that's not something you think is in the scope of this library!

purepani commented 4 weeks ago

Was merged so will close the issue.