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

how RELION extracts _rlnCoordinateX values from the .star file.?? #1102

Open
baratachencho27 opened this issue Apr 5, 2024 · 12 comments
Open

Comments

@baratachencho27
Copy link

Hi there!

I am writing to you because I am facing a problem that might be related to the way RELION extracts or relates the particles in the particles.star file with the mrcs. To put you in context, I have extracted particles from helical segments so from each segment I have several particles, that in the star file are named as 00005@Extract/job352/FoilHole_8416911_Data_846....mrcs.

What I want to do is to mask each particle with a rectangular mask using Xmipp. Thus, I can run a 2D classification of the masked particles in RELION afterwards. I needed to write an script to run the command for each particle. However, I got an error.
I copy here the script and the error after running the file executable:

#!/bin/bash

Define input and output file paths

input_star_file="input.star"
output_star_file="output.star"

Create a new output star file

cp "$input_star_file" "$output_star_file"

Loop through each line in the input star file

while IFS= read -r line; do
# Check if the line is empty
if [ -z "$line" ]; then
continue
fi

# Check if the line contains particle information
if [[ $line == *"_rlnCoordinateX"* ]]; then
    # Extract particle information from the line
    coordinate_x=$(echo "$line" | awk '{print $1}')
    coordinate_y=$(echo "$line" | awk '{print $2}')
    image_name=$(echo "$line" | awk '{print $8}')
    
    # Define input and output paths for the particle mask
    input_mask="$coordinate_x@$image_name:mrcs"
    output_mask="${coordinate_x}_masked@mrcs"
    
    # Run xmipp_transform_mask command for the particle
    /full/path/to/scipion3 xmipp_transform_mask -i "$input_mask" -o "$output_mask" --mask rectangular -104 -168
    
    # Update the line with the new masked image name
    updated_line=$(echo "$line" | sed "s/$image_name/$output_mask/")
    
    # Append the updated line to the output star file
    echo "$updated_line" >> "$output_star_file"
fi

done < "$input_star_file"

ERROR: /process_particles.sh
Scipion v3.3.1 - Eugenius
Xmipp command detected
This method will return the plugin class in the future. Please use getPluginModule instead
XMIPP_ERROR 18: File or directory does not exist.
Cannot access file '_rlnCoordinateX@:mrcs'. It doesn't exist
File: core/xmipp_image_base.cpp line: 588
For more info use --help
Command xmipp_transform_mask "-i" "_rlnCoordinateX@:mrcs" "-o" "_rlnCoordinateX_masked@mrcs" "--mask" "rectangular" "-104" "-168" failed. Exiting with 18
sed: -e expression #1, char 0: no previous regular expression

Do you have any clue of what could be the problem?

Thanks in advance

BEST

@biochem-fan
Copy link
Member

rlnCoordinateX and rlnCoordinateY are particle coordinates in a micrograph. It has nothing to do with the stack index within an MRCS file.

What I want to do is to mask each particle with a rectangular mask using Xmipp

First of all, I don't think this is a good idea. Each segment is in different orientations, so a simple rectangular mask does not necessarily match the direction. Next, sharp edges in a mask are bad for data processing.

@baratachencho27
Copy link
Author

oky, yes I understand. But how can I set a rectangular mask in a 2D classification? I am working with filaments and a rectangular mask would help me to reduce the mask without loosing edge information of the filament

@biochem-fan
Copy link
Member

But how can I set a rectangular mask in a 2D classification?
a rectangular mask would help me to reduce the mask without loosing edge information of the filament

RELION internally does this. You should not modify extracted particles.
Please read the section 2.4 of our paper (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5479445/).

@baratachencho27
Copy link
Author

Hi, well, even though each segment is in different orientations, a rectangular mask will hide everything out the mask so that during 2D alignment will align the segments. Isn´t it?

Thanks

@biochem-fan
Copy link
Member

Did you read the paper above?

@baratachencho27
Copy link
Author

Yes I did, you are talking about the outer diameter of the filament that eventually forms a rectangular mask? I might missunderstand something.

@biochem-fan
Copy link
Member

Yes.

@baratachencho27
Copy link
Author

So what you mean is that if I reduce to the max the set tube diameter during 2D classification, it will as if I was making a rectangular mask of the filaments?
Best

@biochem-fan
Copy link
Member

That is my understanding.

@baratachencho27
Copy link
Author

Hi again!
I am having problems again with the .star file and the extract particles.
First of all, I am creating an star file with the segments of a specific a class:
relion_star_handler --i run_it025_data.star --o run_class50.star --select rlnClassNumber --minval 50 --maxval 50

Written: run_class50.star with 1981 item(s)

Then, I want to use the in-plane angular information be present in the data.star after 2D classification in order to create a stack of aligned segments:

relion_stack_create --i run_class50.star --o run_class50_stack --apply_transformation

However I got the same error all the time: "it says that the file does not exist, and I does!!

WARNING: --apply_transformation uses real space interpolation. It also invalidates CTF parameters (e.g. beam tilt & astigmatism). This can degrade the resolution. USE WITH CARE!!
in: /home/sergio/relion/src/image.h, line 276
ERROR:
Cannot read file Extract/job322/FoilHole_8416910_Data_8465128_8465130_20220209_120844_Fractions.mrcs It does not exist
=== Backtrace ===
relion_stack_create(_ZN11RelionErrorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_l+0x7d) [0x563eb22c890d]
relion_stack_create(_ZN13fImageHandler8openFileERK8FileNamei+0x106d) [0x563eb22b49fd]
relion_stack_create(+0xf2a85) [0x563eb22afa85]
relion_stack_create(_ZN23stack_create_parameters3runEv+0x25e) [0x563eb22bf15e]
relion_stack_create(main+0x4d) [0x563eb22a63ed]
/lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f8c8d280d90]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f8c8d280e40]
relion_stack_create(_start+0x25) [0x563eb22a9e35]

ERROR:
Cannot read file Extract/job322/FoilHole_8416910_Data_8465128_8465130_20220209_120844_Fractions.mrcs It does not exist

Thanks in advance

@baratachencho27
Copy link
Author

When I look at the run_class50.star file. The filename corresponds to this:
000003@Extract/job322/FoilHole_8416910_Data_8465128_8465130_20220209_120844_Fractions.mrcs

@biochem-fan
Copy link
Member

biochem-fan commented Apr 22, 2024

Then, I want to use the in-plane angular information be present in the data.star after 2D classification in order to create a stack of aligned segments:

Why do you want to do this? As the warning says, this will degrade the data quality and is not recommended. You are trying many unusual things with dubious benefits. Didn't our standard, recommended data processing protocol work?

relion_stack_create --i run_class50.star --o run_class50_stack --apply_transformation

Aren't you running this inside the Class2D/jobXXX directory?
The path is relative to the project top directory. So you have to run all commands there.

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

No branches or pull requests

2 participants