I have two questions on creating py script for ROI and using it for cropping volume with Image stack.
My goal is to create ROI for each of the ten segments I have and make separate files with cropped volume.
So for the first part, I found this code
When I tried using it on py interactor, it seems to me that the for loops does not end.
The script works appropriately when I use it for one segment.
I tried to break the loop, but it did not work.
Can anyone tell me what I am doing wrong?
I created annotation ROI and markup ROI to see which one works better with the ImageStack, but the results were not what I expected.
Using Annotation ROI gave me output volume outside the actual CT image, which is probably where the ROI box was before the transform.
Markup ROI gave me output volume that does not match the actual ROI.
Is there any way to solve this problem?
*I use Image stack because I work first in preview mode to separate each sample then work in full resolution for the segmentation process.
Thank you always for your valuable comments.
Is your final goal to save all those 10 segments as individual volumes? If so, splitVolume effect of segment editor would do that without any scripting.
That works way better than the mess I’ve been doing…
Thank you so much for your suggestion!
Can I ask you one more question?
Is there any way to change the existing segment pixel?
The segment I create is in 0.028mm pixel, but I want to smooth this out to 0.007mm after changing the image to a higher resolution.
I have been just resegmenting the sample, and I have a strong feeling that there must be a better method.
You mean you replaced your master volume with a higher resolution one? You can modify the segment geometry an do oversampling of 4. But that will increase your memory consumption quite a bit (64 times to be precise), which may create out memory errors or make everything go slower. If your goal is only splitting these segments at high resolution, then in splitVolume just change the matter volume to the high resolution one.
I am sorry, I think I am not being clear enough.
So after your advice, I used image stack to switch my volume to a higher resolution one and then used splitVolume to split them.
This worked perfectly.
My question is on after splitting the volume and saving them separately.
I wondered if I could reuse the segment created in 0.028mm pixels and edit them in 0.007mm pixels.o
I have changed the master volume of the existing segmentation node, but when I tried to edit the segments, they were still in 0.028mm pixel.
I was able to edit the segments in 0.007 mm pixels after moving them to a new segmentation node.
So I was wondering if this was normal.
Is there any way to edit the segments without moving them to a new segmentation node?
I am also not very clear on what you are trying to do.
If you already split your segments, and while doing that if you chose the master volume to be one with 0.007 mm resolution, your newly derived individual volumes should be resolution. In other words it doesn’t matter if the segmentation is done 0.028 mm (provided that you are still capturing the detail you are need).
Regardless, you can increase the resolution by using the oversampling option of the segment geometry setting. I was just trying to make you aware of increased memory usage.