maweigert / spimagine

GPU accelerated volume rendering / processing in Python
BSD 3-Clause "New" or "Revised" License
117 stars 17 forks source link

Rendering from 2D slices (Beginner's question) #38

Closed Rajalakshmi-Palaniappan closed 2 years ago

Rajalakshmi-Palaniappan commented 2 years ago

Hi, My data is a folder of tiff files (microCT of Heart-1500slices). I'm able to load the tiff folder in spimagine and view the individual slices. May I know how to the render the 3D view from these 2D slices.

maweigert commented 2 years ago

You need to create a 3D stack out of them first, like x = np.stack([tifffile.imread(f) for f in files]).

Rajalakshmi-Palaniappan commented 2 years ago

Hey! Thanks for replying. I tried creating a stack, but even then it's showing up only the slices. I attached the code and the output in viewer along with this showing one of the slices in the stack

img = np.stack([tifffile.imread("/home/rajalakshmi/Segmentation/mv_heart/tiff/%s" %f) for f in sorted(os.listdir(files))]) volshow(img)

Please find the image here: https://i.imgur.com/ZifgmZv.png

maweigert commented 2 years ago

Looks like there is a extra dimension somewhere, what is img.shape? Maybe img = np.squeeze(img) already fixes this.

Rajalakshmi-Palaniappan commented 2 years ago

Hi,

The img.shape was (1502, 2688, 2744, 3). Even after performing np.squeeze also I get the same output (as slices)

maweigert commented 2 years ago

spimagine only supports single channel images, and the order has to be (T,ZY,X), so your last dimension will be interpreted as x dimension. So either:

1) volhow(img[...,0]) to only show a single channel, or
2) volshow(np.moveaxis(img,-1,0))

Rajalakshmi-Palaniappan commented 2 years ago

Hi,

I just needed a single channel and so this worked. Thank you very much for your support!