Skip to content

Commit

Permalink
write_metadata interface now supplies output file name
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoz committed Jun 28, 2021
1 parent 3a50673 commit 3c33007
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
19 changes: 11 additions & 8 deletions isyntax2raw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()):
Expand All @@ -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 = {
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions isyntax2raw/cli/isyntax2raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 3c33007

Please sign in to comment.