diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md new file mode 100644 index 0000000..8a74ec0 --- /dev/null +++ b/DEPENDENCIES.md @@ -0,0 +1,15 @@ +## ImageJ Update Sites needed for `python-imcflibs` + +- ImageJ +- Fiji +- 3D ImageJ-Suite +- clij2 +- IJPB-plugins +- IMCF Uni Basel +- StarDist +- CALM +- TrackMate-Cellpose +- TrackMate-Helper +- TrackMate-StarDist +- TrackMate-Weka +- TrackMate-MorpholibJ diff --git a/src/imcflibs/imagej/bdv.py b/src/imcflibs/imagej/bdv.py index 5cc7b41..29524af 100644 --- a/src/imcflibs/imagej/bdv.py +++ b/src/imcflibs/imagej/bdv.py @@ -1593,14 +1593,23 @@ def fuse_dataset( def fuse_dataset_bdvp( project_path, command, - processing_opts=None, result_path=None, - compression="LZW", + range_channels="", + range_slices="", + range_frames="", + n_resolution_levels=5, + use_lzw_compression=True, + split_slices=False, + split_channels=False, + split_frames=False, + override_z_ratio=False, + z_ratio=1.0, + use_interpolation=True, ): """Export a BigDataViewer project using the BIOP Kheops exporter. - Use the BIOP Kheops exporter to convert a BigDataViewer project into - OME-TIFF files, with optional compression. + Use BIOP Kheops exporter to fuse a BigDataViewer project and save + it as pyramidal OME-TIFF. Parameters ---------- @@ -1608,43 +1617,74 @@ def fuse_dataset_bdvp( Full path to the BigDataViewer XML project file. command : CommandService The Scijava CommandService instance to execute the export command. - processing_opts : ProcessingOptions, optional - Options defining which parts of the dataset to process. If None, default - processing options will be used (process all angles, channels, etc.). result_path : str, optional Path where to store the exported files. If None, files will be saved in the same directory as the input project. - compression : str, optional - Compression method to use for the TIFF files. Default is "LZW". + range_channels : str, optional + Channels to include in the export. Default is all channels. + range_slices : str, optional + Slices to include in the export. Default is all slices. + range_frames : str, optional + Frames to include in the export. Default is all frames. + n_resolution_levels : int, optional + Number of pyramid resolution levels to use for the export. Default is 5. + use_lzw_compression : bool, optional + If True, compressed the output file using LZW. Default is True. + split_slices : bool, optional + If True, splits the output into separate files for each slice. Default is False. + split_channels : bool, optional + If True, splits the output into separate files for each channel. Default is False. + split_frames : bool, optional + If True, splits the output into separate files for each frame. Default is False. + override_z_ratio : bool, optional + If True, overrides the default z_ratio value. Default is False. + z_ratio : float, optional + The z ratio to use for the export. Default is 1.0. + use_interpolation : bool, optional + If True, interpolates during fusion (takes ~4x longer). Default is True. Notes ----- This function requires the PTBIOP update site to be enabled in Fiji/ImageJ. + + Examples + -------- + fuse_dataset_bdvp(xml_input, cs) """ - if processing_opts is None: - processing_opts = ProcessingOptions() file_info = pathtools.parse_path(project_path) if not result_path: result_path = file_info["path"] - # if not os.path.exists(result_path): - # os.makedirs(result_path) command.run( FuseBigStitcherDatasetIntoOMETiffCommand, True, - "image", + "xml_bigstitcher_file", project_path, - "output_dir", + "output_path_directory", result_path, - "compression", - compression, - "subset_channels", - "", - "subset_slices", - "", - "subset_frames", - "", - "compress_temp_files", - False, + "range_channels", + range_channels, + "range_slices", + range_slices, + "range_frames", + range_frames, + "n_resolution_levels", + n_resolution_levels, + "fusion_method", + "SMOOTH AVERAGE", + "use_lzw_compression", + use_lzw_compression, + "split_slices", + split_slices, + "split_channels", + split_channels, + "split_frames", + split_frames, + "override_z_ratio", + override_z_ratio, + "z_ratio", + z_ratio, + "use_interpolation", + use_interpolation, ) diff --git a/src/imcflibs/imagej/trackmate.py b/src/imcflibs/imagej/trackmate.py index 4433a8b..b8a634f 100644 --- a/src/imcflibs/imagej/trackmate.py +++ b/src/imcflibs/imagej/trackmate.py @@ -235,6 +235,44 @@ def spot_filtering( return settings +def set_spotfilter(settings, filter_key, filter_value): + """Sets a TrackMate spot filter with specified filter key and values. + + Parameters + ---------- + settings : fiji.plugin.trackmate.Settings + Dictionary containing all the settings to use for TrackMate. + filter_name : str + The name of the filter to be applied. You must use the keys of the features, not their name. + Here is the table of the feature keys and names for the spot features: + https://imagej.net/plugins/trackmate/scripting/trackmate-detectors-trackers-keys + filter_value : list + A list containing two values for the filter. The first value is + applied as an above-threshold filter, and the second as a below-threshold filter. + + Returns + ------- + Settings + The modified TrackMate settings dict with added spot filters + + Example + ------- + >>> # Set an above-threshold filter value for spot "QUALITY" without a below-threshold value + >>> tm_settings = set_trackmate_spotfilter(tm_settings, 'QUALITY', [120, None]) + """ + + settings.addAllAnalyzers() + if filter_value[0] != None: + filter_low = FeatureFilter(filter_key, filter_value[0], True) + settings.addSpotFilter(filter_low) + if filter_value[1] != None: + filter_high = FeatureFilter(filter_key, filter_value[1], False) + settings.addSpotFilter(filter_high) + + return settings + + + def sparse_lap_tracker(settings): """Create a sparse LAP tracker with default settings.