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.convert_dm4.get_stage_position(dm4file)[source]

Extract the stage position from the DM4 file’s metadata.

coseda.importers.convert_dm4.process_and_save_h5(dm4_file_path, output_h5_file, bin_factor)[source]

Process DM4 file and save it as 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.gatan_metareader.extract_frame_timestamp_from_gatan_metadata(framefile_path)[source]
coseda.importers.gatan_metareader.extract_info_from_gatan_metadata(input_path)[source]
coseda.importers.gatan_metareader.find_all_frames_ordered(parent_folder)[source]
coseda.importers.gatan_metareader.get_timestamp_from_path(path)[source]
coseda.importers.gatan_metareader.parse_dm4_metadata(dm4file)[source]

coseda.importers.h5convert module

coseda.importers.h5convert.bin_chunk(chunk, bin_factor)[source]

Bin the image data. :param chunk: numpy array of image data :param bin_factor: integer binning factor :return: binned numpy array

coseda.importers.h5convert.calculate_mean_intensity_per_frame_batch(input_path)[source]
coseda.importers.h5convert.calculate_total_intensity_per_frame_batch(input_path)[source]
coseda.importers.h5convert.dm4_folder_conversion_batch(input_path)[source]
coseda.importers.h5convert.emd_to_h5(input_path)[source]
coseda.importers.h5convert.emi_to_h5(input_path)[source]
coseda.importers.h5convert.velox_true_conversion_batch(input_path)[source]

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.create_insfile_mrc(input_path, target=None, source_path=None)[source]
coseda.importers.import_mrc.create_insfiles_mrc_batch(input_path, target=None)[source]
coseda.importers.import_mrc.extract_info_from_mrc_metadata(input_path)[source]
coseda.importers.import_mrc.get_mrc_files(input_paths)[source]
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.create_insfiles_tiff(input_path, target)[source]
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_tiff.tiff_conversion(ini_file_path)[source]
coseda.importers.import_tiff.tiff_conversion_batch(input_path)[source]

coseda.importers.import_velox module

coseda.importers.import_velox.add_intesities_batch(input_path)[source]
coseda.importers.import_velox.calculate_mean_intensities(h5file_path)[source]
coseda.importers.import_velox.calculate_mean_intensities_chunked(h5file_path, batch_size=1000)[source]
coseda.importers.import_velox.calculate_total_intensities(h5file_path)[source]
coseda.importers.import_velox.calculate_total_intensities_chunked(h5file_path, batch_size=1000)[source]
coseda.importers.import_velox.decode_column(metadata, column_index, limit=None)[source]
coseda.importers.import_velox.export_hdf5_images_to_tiff(hdf5_path, output_dir)[source]
coseda.importers.import_velox.extract_instrument_data(input_type, originalfile_path)[source]
coseda.importers.import_velox.extract_pos_data(h5file_path, datapath)[source]
coseda.importers.import_velox.extract_stage_pos(decoded_metadata)[source]
coseda.importers.import_velox.find_dataset_paths(h5file_path)[source]
coseda.importers.import_velox.find_path_in_h5(h5file)[source]
coseda.importers.import_velox.get_image_mode(dtype)[source]
coseda.importers.import_velox.plot_4Dstem(input_path)[source]
coseda.importers.import_velox.plot_crystamorphus(input_path)[source]
coseda.importers.import_velox.refine_stagepos_x(h5file_path)[source]
coseda.importers.import_velox.remap_framestack(h5file_path, framepath, chunked=True, chunk_size=(1000, 1024, 1024))[source]
coseda.importers.import_velox.save_4Dstem(input_path)[source]
coseda.importers.import_velox.velox_batch(input_folder)[source]
coseda.importers.import_velox.velox_process(input_path)[source]
coseda.importers.import_velox.velox_true_conversion(h5file_path, chunk_size=(1000, 1024, 1024))[source]
coseda.importers.import_velox.write_stage_pos_to_hdf5(stage_positions, workingfile)[source]

Module contents

Importer and conversion modules.