Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image index prefix in filename with mrc extension #705

Closed
joton opened this issue Nov 3, 2020 · 4 comments · Fixed by #709
Closed

Image index prefix in filename with mrc extension #705

joton opened this issue Nov 3, 2020 · 4 comments · Fixed by #709

Comments

@joton
Copy link
Collaborator

joton commented Nov 3, 2020

When input is a starfile, relion_image_handler composes the output filename by adding the index number prefix even if output image file is containing one single image instead of a stack. There's no bug here. However, when that output starfile is used as input with images being 3d subtomograms, Image class throws an error trying to read them because an image index is passed and extension is not MRCS.

Which strategy should we follow to fix it? to correct the output starfile in image_handler and other programs as they show up or allowing Image class to read files with select_img=0 (instead of -1) and mrc extension? I think the former should be fixed to be coherent with input. The latter would be make image read more flexible but I don't know if that would break something elsewhere.

@biochem-fan
Copy link
Member

Can you give me examples (input file names, output file names, etc) of the problems and proposed two solutions?

@joton
Copy link
Collaborator Author

joton commented Nov 3, 2020

Sure!

The input star file contains file names like "subtomograms/ini_10k/0_data.mrc"

After running the command "relion_image_handler --i subtomograms/ini_10k_particles_bug.star --o DELETEME --phase_randomise 6" I get the files properly processed and the output star file "subtomograms/ini_10k_particles_bug_DELETEME.star" whose image file names are now like "000001@subtomograms/ini_10k/0_data_DELETEME.mrc".

To fix relion_image_handler we'd need to modify a couple of blocks: we should check whether real image files within the starfile are stacks instead of setting input_is_stack to True directly (image_handler.cpp:718), replacing by

FileName fn_img;
MD.getValue(EMDL_IMAGE_NAME, fn_img, 0);
fn_img.decompose(slice_id, fn_stem);
input_is_stack = (fn_in.getExtension() == "mrcs" || fn_in.getExtension() == "tif" || fn_in.getExtension() == "tiff") && (slice_id == -1);

Then, for my_fn_out composition in lines 980-991 we must consider when input_is_star is True while input_is_stack is False inserting the suffix without adding the index number prefix.

Fixing image class is far simpler. We could read .mrc extension filenames with index number prefix if index == 1, replacing in image.h:1397 " select_img >= 0" by "select_img >0"

Line references are for master branch at current commit (89480b1). I tested both changes and they fix my problem. I could commit them but, although the logic looks quite simple, I prefer to follow your suggestions.

@biochem-fan
Copy link
Member

Thanks for your explanation. Now it is clear.

I think the first proposal is better. Please test your change in a single particle dataset (e.g. our tutorial dataset's run_data.star) too and send me a pull request. If this should be a part of 3.1.x, send it to ver3.1 branch here. Otherwise, please send it to master of relion-devel.

@biochem-fan
Copy link
Member

@joton How is it going? Do you need my help on testing?

joton added a commit that referenced this issue Nov 10, 2020
biochem-fan added a commit that referenced this issue Nov 10, 2020
Fixes image numbering in filename for files other than stacks in starfiles #705
biochem-fan pushed a commit that referenced this issue Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants