coseda.importers package¶
Submodules¶
coseda.importers.convert_dm4 module¶
- coseda.importers.convert_dm4.bin_chunk(chunk, bin_factor)[source]¶
Bins the chunk of images by the specified bin factor.
- coseda.importers.convert_dm4.dm4_to_h5(dm4_file_path, output_folder, bin_factor=1)[source]¶
Converts a DM4 file to an HDF5 file.
coseda.importers.gatan_metareader module¶
- coseda.importers.gatan_metareader.dm4_folder_conversion(dm4parentfolder, outputfolder, logfile_path, extract_timestamp=True, chunk_size=(1000, 1024, 1024))[source]¶
coseda.importers.h5convert module¶
coseda.importers.import_h5 module¶
- coseda.importers.import_h5.check_image_dataset(h5_path, dataset_path='/entry/data/images')[source]¶
Check whether dataset_path exists in the HDF5 file at h5_path, and whether it has exactly 3 dimensions (frames × height × width).
- Returns:
(True, shape) if it exists and ndim == 3 (False, None) if it doesn’t exist or file cannot be opened (False, shape) if it exists but shape is not 3D
- Parameters:
h5_path (str)
dataset_path (str)
- Return type:
Tuple[bool, Tuple[int, int, int] | None]
- coseda.importers.import_h5.get_dataset_chunk_info(h5_path, dataset_path='/entry/data/images')[source]¶
Check if dataset_path exists, is 3D, and is chunked in the HDF5 file at h5_path.
- Returns:
(True, chunks) if the dataset exists, is 3D, and uses chunked storage (chunks is tuple of chunk sizes) (True, ()) if it exists, is 3D, but uses contiguous storage (no chunking) (False, None) if the dataset is missing, not 3D, or the file cannot be opened
- Parameters:
h5_path (str)
dataset_path (str)
- Return type:
Tuple[bool, Tuple[int, …] | None]
- coseda.importers.import_h5.is_dataset_chunked_first_dim(h5_path, dataset_path='/entry/data/images')[source]¶
Check whether dataset_path in the HDF5 file at h5_path is stored with chunking (i.e., has a non-None chunks tuple). Specifically tests that the dataset uses HDF5 chunked storage, which implies chunking along all dims, including the first.
- Returns:
(True, chunks) if the dataset exists and is chunked (chunks is the chunk shape tuple) (False, None) if the dataset does not exist, cannot be opened, or is not chunked
- Parameters:
h5_path (str)
dataset_path (str)
- Return type:
Tuple[bool, Tuple[int, …] | None]
- coseda.importers.import_h5.move_plain_h5(ini_path)[source]¶
Move and rename the original HDF5 file according to the INI’s Paths section.
- Reads from the INI [Paths]:
‘hdf5_file’ / ‘hdf5_input’ / ‘hdf5_file_path’: original HDF5 path.
‘output_folder’ / ‘output_directory’: target directory.
Renames the HDF5 to match the INI basename: <ini_basename>.h5, moves it into the output folder (creating it if needed), and returns the new HDF5 file path.
- Parameters:
ini_path (str)
- Return type:
str
coseda.importers.import_mrc module¶
- coseda.importers.import_mrc.mrc_folder_conversion(mrc_source, outputfolder, logfile_path, chunk_size=1000, acceleration_voltage=None, camera_length=None, camera_length_correction=1.0, goniometer_transform_order=None)[source]¶
- coseda.importers.import_mrc.mrc_folder_conversion_batch(input_path, continue_on_error=False, return_errors=False)[source]¶
Convert one or many MRC import INIs to H5.
- Parameters:
input_path (str | list[str]) – Path(s) accepted by handle_input.
continue_on_error (bool) – If True, process all config files and collect failures. If False, stop at first failure (legacy behavior).
return_errors (bool) – If True, return (success: bool, errors: list[str]). If False, return only success: bool (legacy behavior).
coseda.importers.import_tiff module¶
- coseda.importers.import_tiff.find_tiff_frame_files(tiff_folder)[source]¶
Return TIFF filenames in a stable natural order.
- coseda.importers.import_tiff.set_tiffconversion_parameters(ini_file_path, compression=None, compression_level=None)[source]¶
- coseda.importers.import_tiff.stupid_tiff_folder_conversion(tiffparentfolder, outputfolder, logfile_path, start_frame=1000000, frame_files=None, chunk_size=(1000, 512, 512), compression=None, compression_level=4, extension='.tiff', acceleration_voltage=None, camera_length=None, camera_length_correction=1.0, goniometer_transform_order=None)[source]¶
coseda.importers.import_velox module¶
- coseda.importers.import_velox.calculate_mean_intensities_chunked(h5file_path, batch_size=1000)[source]¶
- coseda.importers.import_velox.calculate_total_intensities_chunked(h5file_path, batch_size=1000)[source]¶
- coseda.importers.import_velox.remap_framestack(h5file_path, framepath, chunked=True, chunk_size=(1000, 1024, 1024))[source]¶
Module contents¶
Importer and conversion modules.