wedgeutils#
- cryocat.utils.wedgeutils.apply_wedge_mask(wedge_mask, in_map, rotation_zxz=None, output_path=None)#
- cryocat.utils.wedgeutils.check_data_consistency(data1, data2, data_type1, data_type2)#
Check the consistency of two sets of data.
- Parameters:
- data1numpy.ndarray
The first set of data.
- data2numpy.ndarray
The second set of data.
- data_type1str
The type of data in data1.
- data_type2str
The type of data in data2.
- Returns:
- None
This function does not return anything.
- Raises:
- TypeError
If data1 or data2 isn’t numpy.ndarray type.
- ValueError
If the number of entries in data1 is different from the number of entries in data2.
- cryocat.utils.wedgeutils.create_wedge_list_em_batch(tomo_list, tlt_file_format, output_file=None)#
Create a wedge list dataframe in EM format for all tomograms/tilt series specified in tomo_list.
- Parameters:
- tomo_liststr or array-like
The path to the file containing list of tomograms (txt) or tomogram/tilt series numbers specified as array-like variable. See
cryocat.ioutils.tlt_load()for more information on formatting.- tlt_file_formatstr
The format describing name of the input files (including the path) with tilt angles. See
Notesbelow for more information. Seecryocat.ioutils.tlt_load()for more information on allowed input files (tlt, mdoc, xml).- output_filestr, optional
The path to the output file, by default None. If None, the output is not written out.
- Returns:
- pandas.DataFrame
The wedge list dataframe in EM format for all tomograms/tilt series specified by tomo_list.
See also
cryocat.ioutils.tlt_load()
Notes
The variables with _file_format in name should contain pattern that will be replaced by tomogram/tilt series numbers specified in the tomo_list. The pattern should start with $ and should be followed by sequnece of x. The sequence of x will be replaced by tomogram/tilt series number from tomo_list and pad with zeros if necessary. For example, if tlt_file_format is specified as “TS_$xxx/$xxx.tlt” and the tomo_list contains numbers 79 and 155, the final file names will be TS_079/079.tlt and TS_155/155.tlt. The sequence of x can be of arbitrary length, even within one file format, e.g. “TS_$xxxx/$xxx.tlt”. However, the minimal allowed length of the sequence is given by the number of digits of the largest tomogram/tilt series number. For instance, TS_$xx/$xxx.tlt will fail since tomogram 155 requires sequence of at least 3 x. It is expected that all files of the same type will follow same formatting. Different file types can follow different formatting. For example, the tlt_file_format can be TS_$xxx/$xxx.tlt but defocus files can be all in one folder specified as “ctf_files/$xxxx_ctffind4.txt”.
- cryocat.utils.wedgeutils.create_wedge_list_sg(tomo_id, tomo_dim, pixel_size, tlt_file, z_shift=0.0, ctf_file=None, ctf_file_type='gctf', dose_file=None, voltage=300.0, amp_contrast=0.07, cs=2.7, output_file=None, drop_nan_columns=True)#
Create a wedge list dataframe for a single tomogram/tilt series in STOPGAP format.
- Parameters:
- tomo_idint
The ID of the tomogram.
- tomo_dimstr or array-like
The path to the tomogram dimensions file or dimensions specified as array-like variable. See
cryocat.ioutils.dimensions_load()for more information on formatting.- pixel_sizefloat
The pixel size of the tomogram/tilt series.
- tlt_filestr or array-like
The path to the file containing information on tilts (tlt, mdoc, xml) or tilt angles specified as array-like variable. See
cryocat.ioutils.tlt_load()for more information on formatting.- z_shiftstr or array-like or int or float, default=0.0
The path to the file containing information on z-shift (txt, com) or z-shift specified as array-like, pandas DataFrame, int or float. See
cryocat.ioutils.z_shift_load()for more information on formatting.- ctf_filestr or pandas.DataFrame or array-like, optional
Either the path to the file with defocus values - either in gctf (star), ctffind4 (txt) or warp (xml) format or array like structure of size Nx5 (N is number of tilts), or pandas.DataFrame. See
cryocat.ioutils.defocus_load()for more information on formatting.- ctf_file_typestr, {“gctf”, “ctffind4”, “warp”}
The type of the CTF file with defocus values. It can be either “gctf”, “ctffind4”, “warp”, defaults to “gctf”.
- dose_filestr or array-like, optional
The path to the file containing information on corrected dose (csv, mdoc, txt, xml) or the corrected dose specified as array-like variable. See
cryocat.ioutils.total_dose_load()for more information on formatting.- voltagefloat, default=300.0
The voltage of the microscope, defaults to 300.0.
- amp_contrastfloat, default=0.07
The amplitude contrast of the microscope, defaults to 0.07.
- csfloat, default=2.7
The spherical aberration coefficient, defaults to 2.7.
- output_filestr, optional
The path to the output file, by default None. If None, the output is not written out.
- drop_nan_columnsbool, default=True
Whether to drop columns with NaN values, defaults to True.
- Returns:
- pandas.DataFrame
The wedge list dataframe in STOPGAP format for single tomogram/tilt series.
See also
cryocat.ioutils.tlt_load(),cryocat.ioutils.z_shift_load(),cryocat.ioutils.defocus_load()cryocat.ioutils.total_dose_load()
- cryocat.utils.wedgeutils.create_wedge_list_sg_batch(tomo_list, pixel_size, tlt_file_format, tomo_dim=None, tomo_dim_file_format=None, z_shift=0.0, z_shift_file_format=None, ctf_file_format=None, ctf_file_type='gctf', dose_file_format=None, voltage=300.0, amp_contrast=0.07, cs=2.7, output_file=None)#
Create a wedge list dataframe in STOPGAP format for all tomograms/tilt series specified in tomo_list.
- Parameters:
- tomo_liststr or array-like
The path to the file containing list of tomograms (txt) or tomogram/tilt series numbers specified as array-like variable.
- pixel_sizefloat
The pixel size of the tomogram/tilt series. The pixel size has to be same for all tomograms/tilt series otherwise STOPGAP will not accept it.
- tlt_file_formatstr
The format describing name of the input files (including the path) with tilt angles. See
Notesbelow for more information. Seecryocat.ioutils.tlt_load()for more information on allowed input files (tlt, mdoc, xml).- tomo_dimarray-like, optional
Tomogram dimensions specified as array-like variable. See
cryocat.ioutils.dimensions_load()for more information on formatting. Defaults to None but either tomo_dim or tomo_dim_file_format has to be specified.- tomo_dim_file_formatstr, optional
The format describing name of the input files (including the path) with tomogram dimensions. See
Notesbelow for more information. Seecryocat.ioutils.dimensions_load()for more information on allowed input files (txt, com). Defaults to None but either tomo_dim or tomo_dim_file_format has to be specified.- z_shiftarray-like or dataframe or int or float, default=0.0
Z-shift specified as array-like, pandas DataFrame, int or float. See
cryocat.ioutils.z_shift_load()for more information on input types. Defaults to 0.0.- z_shift_file_formatstr, optional
The format describing name of the input files (including the path) with z-shift. See
Notesbelow for more information. Seecryocat.ioutils.z_shift_load()for more information on allowed input files (com, txt). Defaults to None.- ctf_file_formatstr, optional
The format describing name of the input files (including the path) with defocus values. See
Notesbelow for more information. Supported formats are gctf (star file), ctffind4 (txt file) and warp (xml file). Defaults to None. Seecryocat.ioutils.defocus_load()on more information of file formats.- ctf_file_typestr, {“gctf”, “ctffind4”, “warp”}
The type of the CTF file with defocus values. It can be either “gctf”, “ctffind4”, or “warp”, defaults to “gctf”.
- dose_file_formatstr or array-like, optional
The format describing name of the input files (including the path) with corrected dose. See
Notesbelow for more information. Seecryocat.ioutils.total_dose_load()for more information on allowed input files (txt, mdoc, xml). Defaults to None.- voltagefloat, default=300.0
The voltage of the microscope, defaults to 300.0.
- amp_contrastfloat, default=0.07
The amplitude contrast of the microscope, defaults to 0.07.
- csfloat, default=2.7
The spherical aberration coefficient, defaults to 2.7.
- output_filestr, optional
The path to the output file, by default None. If None, the output is not written out. Defaults to None.
- Returns:
- pandas.DataFrame
The wedge list dataframe in STOPGAP format for all tomograms/tilt series specified by tomo_list.
- Raises:
- ValueError
If neither tomo_dim or tomo_dim_file_format is specified.
See also
cryocat.ioutils.tlt_load(),cryocat.ioutils.z_shift_load(),cryocat.ioutils.defocus_load()cryocat.ioutils.total_dose_load()
Notes
The variables with _file_format in name should contain pattern that will be replaced by tomogram/tilt series numbers specified in the tomo_list. The pattern should start with $ and should be followed by sequnece of x. The sequence of x will be replaced by tomogram/tilt series number from tomo_list and pad with zeros if necessary. For example, if tlt_file_format is specified as “TS_$xxx/$xxx.tlt” and the tomo_list contains numbers 79 and 155, the final file names will be TS_079/079.tlt and TS_155/155.tlt. The sequence of x can be of arbitrary length, even within one file format, e.g. “TS_$xxxx/$xxx.tlt”. However, the minimal allowed length of the sequence is given by the number of digits of the largest tomogram/tilt series number. For instance, TS_$xx/$xxx.tlt will fail since tomogram 155 requires sequence of at least 3 x. It is expected that all files of the same type will follow same formatting. Different file types can follow different formatting. For example, the tlt_file_format can be TS_$xxx/$xxx.tlt but defocus files can be all in one folder specified as “ctf_files/$xxxx_ctffind4.txt”.
- cryocat.utils.wedgeutils.create_wg_mask(wg_list_star_df, tomo_list, box_size, shape='wedge', output_path=None)#
- cryocat.utils.wedgeutils.load_wedge_list_em(input_data)#
Load an EM wedge list from various input formats.
- Parameters:
- input_datastr, np.ndarray, or pd.DataFrame
The input data can be one of the following: - A string representing the file path to a data source. - A 2D numpy array with a shape of (n, 3), where n is the number of wedges. - A pandas DataFrame containing wedge data.
- Returns:
- pd.DataFrame
A DataFrame containing the wedge list with columns: - ‘tomo_id’: Identifier for the tomograms. - ‘min_tilt_angle’: Minimum tilt angle. - ‘max_tilt_angle’: Maximum tilt angle.
- Raises:
- ValueError
If the input_data is not of a valid type or does not conform to the expected shape.
- cryocat.utils.wedgeutils.load_wedge_list_sg(input_data)#
Load a STOPGAP wedge list from a file or a pandas DataFrame.
- Parameters:
- input_datastr or pd.DataFrame
The input data can either be a file path (string) to a star file or a pandas DataFrame containing the wedge list.
- Returns:
- pd.DataFrame
A DataFrame containing the wedge list extracted from the input data.
- Raises:
- ValueError
If the input_data is neither a string nor a pandas DataFrame.
- cryocat.utils.wedgeutils.wedge_list_sg_to_em(input_path, output_path, write_out=True)#
Convert a STOPGAP star format wedge list into a em wedge list; only 3 columns [tomo_id, min_tilt_angle, max_tilt_angle] are collected
- Parameters:
- input_path: str
Path to a STOPGAP star wedge list.
- output_path: str
Path to save the new em format wedge list.
- write_out: bool, default=True
Whether to save the output. Default is True.