ccpem/mrcfile

Having trouble while saving the image into .TIF

Yuvi-416 opened this issue · 4 comments

Hi there,
First of all, thank you for this wonderful package in the python environment.
I have downloaded the MRC file from here: https://www.ebi.ac.uk/empiar/EMPIAR-10324/ and was trying to save each slice in a .tif format. The code run very well but the saved image is not very good, you can see the generated image below.
https://uapt33090-my.sharepoint.com/:f:/g/personal/ygupta_ua_pt/Eh0yGt6IzTZOh703l3KY0JcB2zAG46W_TaemNLJNWNk2Dw?e=OJTUtQ
code:

i = mrcfile.open(input1)
for ii in range(i.data.shape[0]):
    ii = 43
    tifffile.imwrite(str(output) + f'{ii}.tif', i.data[ii])

But when I try to save the MRC image into .tif utilizing the IMOD LINUX package it works perfectly.
Can you help me why I am not getting satisfactory images in python?
Thank you!

Hi there,
I follow your advice. The first option didn't work and the second option worked but it squeezes the x-axis. I don't know whether I add 128 correctly or not.
For example:
i.shape = (361, 1670, 1562) but after applying i.data.dype»»»int16, it squeezes the image width as (1670, 781).

Here's the code:

i = mrcfile.open(input1)
i.data.dtype = np.int16
np.append(i.data, 128)

for ii in range(i.data.shape[0]):
    tifffile.imwrite(str(output) + f'{ii}.tif', i.data[ii])

Image has int8 dtype.

Thank you!