diff --git a/isyntax2raw/__init__.py b/isyntax2raw/__init__.py index b8e65c3..f78f15e 100644 --- a/isyntax2raw/__init__.py +++ b/isyntax2raw/__init__.py @@ -375,14 +375,13 @@ def wait_any(self, regions): else: return self.pixel_engine.wait_any(regions) - def write_metadata_json(self): + def write_metadata_json_cli(self): + self.write_metadata_json(self.slide_directory) + + def write_metadata_json(self, output_file_path): '''write metadata to a JSON file''' - os.makedirs(os.path.join(self.slide_directory, "OME"), exist_ok=True) - metadata_file = os.path.join( - self.slide_directory, "OME", "METADATA.json" - ) - with open(metadata_file, "w", encoding="utf-8") as f: + with open(output_file_path, "w", encoding="utf-8") as f: metadata = self.get_metadata() for image in range(self.num_images()): @@ -392,7 +391,6 @@ def write_metadata_json(self): json.dump(metadata, f) def write_metadata_xml(self): - os.makedirs(os.path.join(self.slide_directory, "OME"), exist_ok=True) ome_timestamp = self.acquisition_datetime() xml_values = { @@ -430,7 +428,12 @@ def write_metadata_xml(self): omexml.write(xml) def write_metadata(self): - self.write_metadata_json() + os.makedirs(os.path.join(self.slide_directory, "OME"), exist_ok=True) + metadata_file = os.path.join( + self.slide_directory, "OME", "METADATA.json" + ) + + self.write_metadata_json(metadata_file) self.write_metadata_xml() def get_size(self, dim_range): diff --git a/isyntax2raw/cli/isyntax2raw.py b/isyntax2raw/cli/isyntax2raw.py index 0390062..8bec27b 100644 --- a/isyntax2raw/cli/isyntax2raw.py +++ b/isyntax2raw/cli/isyntax2raw.py @@ -83,13 +83,13 @@ def write_tiles( help="enable debugging", ) @click.argument('input_path') -@click.argument('output_path') -def write_metadata(debug, input_path, output_path): +@click.argument('output_file') +def write_metadata(debug, input_path, output_file): with WriteTiles( None, None, None, None, - None, None, None, input_path, output_path + None, None, None, input_path, output_file ) as wt: - wt.write_metadata_json() + wt.write_metadata_json_cli() def main():