|
def get_metadata(input_dir: str): |
|
""" |
|
Extract acquisition date, pixel-size information, acquisition camera |
|
index, and channel information (laser, filter and objective) from a |
|
Yokogawa CV7000 or CV8000 acquisition. The information is extracted from |
|
mse- and mrf-files written by Yokogawa. |
|
|
|
:param input_dir: location of the Yokogawa acquisition |
|
:return: acquisition_date, pixel_size, pixel_size_unit, channel_information |
|
""" |
|
mrf_file = join(input_dir, "MeasurementDetail.mrf") |
|
|
|
mrf_tree = ET.parse(mrf_file) |
|
mrf_root = mrf_tree.getroot() |
|
mrf_ns = mrf_root.tag.replace("MeasurementDetail", "") |
|
|
|
date_format_str = mrf_root.attrib[mrf_ns + "BeginTime"] |
|
date = parser.parse(date_format_str) |
|
acquisition_date_str = date.strftime("%Y-%m-%d") |
|
|
|
channels = {} |
|
for child in mrf_root: |
|
ch = child.get(mrf_ns + "Ch") |
|
if ch is not None: |
|
channels[ch] = { |
|
"pixel_size": child.get(mrf_ns + "HorizontalPixelDimension"), |
|
"cam_index": child.get(mrf_ns + "CameraNumber"), |
|
} |
|
|
|
pixel_size = float(mrf_root[1].attrib.get(mrf_ns + "HorizontalPixelDimension")) |
|
pixel_size_unit = "micron" |
|
|
|
mes_file = glob(join(input_dir, "*.mes"))[0] |
|
|
|
mes_tree = ET.parse(mes_file) |
|
mes_root = mes_tree.getroot() |
|
mes_ns = mes_root.tag.replace("MeasurementSetting", "") |
|
|
|
for child in mes_root[2]: |
|
ch = child.get(mes_ns + "Ch") |
|
if ch is not None: |
|
channel_dict = channels[ch] |
|
channel_dict["objective"] = child.get(mes_ns + "Objective").replace( |
|
" ", "-" |
|
) |
|
channel_dict["filter"] = child.get(mes_ns + "Acquisition").replace("/", "-") |
|
channel_dict["laser"] = child[0].text |
|
|
|
return acquisition_date_str, pixel_size, pixel_size_unit, channels |
Currently, we have:
For metadata
hcsfaim-ipa/src/faim_ipa/hcs/cellvoyager/acquisition.py
Lines 238 to 277 in b65f215
and
faim-ipa/src/faim_ipa/hcs/cellvoyager/acquisition.py
Lines 189 to 211 in b65f215
eicmfaim-ipa/src/faim_ipa/eicm/preprocessing/cellvoyager.py
Lines 13 to 61 in b65f215
For acquisition files
hcsfaim-ipa/src/faim_ipa/hcs/cellvoyager/acquisition.py
Lines 279 to 305 in b65f215
eicmfaim-ipa/src/faim_ipa/eicm/preprocessing/cellvoyager.py
Lines 86 to 128 in b65f215
We should try to consolidate those two code bases (and maybe even use the metadata model from https://github.com/tlambert03/ome-types to standardize the way we handle metadata, see #198):
faim_ipa.hcs.cellvoyager.utils)StackAcquisitionclass