metamorph-mda-parser 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- metamorph_mda_parser-0.0.1/.github/workflows/test.yml +42 -0
- metamorph_mda_parser-0.0.1/.gitignore +3 -0
- metamorph_mda_parser-0.0.1/LICENSE.txt +11 -0
- metamorph_mda_parser-0.0.1/PKG-INFO +48 -0
- metamorph_mda_parser-0.0.1/README.md +25 -0
- metamorph_mda_parser-0.0.1/pyproject.toml +83 -0
- metamorph_mda_parser-0.0.1/src/metamorph_mda_parser/__init__.py +0 -0
- metamorph_mda_parser-0.0.1/src/metamorph_mda_parser/nd.py +132 -0
- metamorph_mda_parser-0.0.1/tests/__init__.py +0 -0
- metamorph_mda_parser-0.0.1/tests/resources/sample_2ch_75pos_361t.nd +93 -0
- metamorph_mda_parser-0.0.1/tests/resources/sample_4ch_4pos.nd +25 -0
- metamorph_mda_parser-0.0.1/tests/test_nd.py +68 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, master]
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: test-${{ github.head_ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
env:
|
|
14
|
+
PYTHONUNBUFFERED: "1"
|
|
15
|
+
FORCE_COLOR: "1"
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
run:
|
|
19
|
+
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
|
|
20
|
+
runs-on: ${{ matrix.os }}
|
|
21
|
+
strategy:
|
|
22
|
+
fail-fast: false
|
|
23
|
+
matrix:
|
|
24
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
25
|
+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
|
|
26
|
+
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v3
|
|
29
|
+
|
|
30
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
31
|
+
uses: actions/setup-python@v4
|
|
32
|
+
with:
|
|
33
|
+
python-version: ${{ matrix.python-version }}
|
|
34
|
+
|
|
35
|
+
- name: Install Hatch
|
|
36
|
+
run: pip install --upgrade hatch
|
|
37
|
+
|
|
38
|
+
- name: Run static analysis
|
|
39
|
+
run: hatch fmt --check
|
|
40
|
+
|
|
41
|
+
- name: Run tests
|
|
42
|
+
run: hatch run cov
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Copyright (c) 2024-present Jan Eglinger <jan.eglinger@fmi.ch>.
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
+
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
+
|
|
7
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
+
|
|
9
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
+
|
|
11
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: metamorph-mda-parser
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Light-weight parsing of Metamorph/VisiView .nd files.
|
|
5
|
+
Project-URL: Documentation, https://github.com/fmi-faim/metamorph-mda-parser#readme
|
|
6
|
+
Project-URL: Issues, https://github.com/fmi-faim/metamorph-mda-parser/issues
|
|
7
|
+
Project-URL: Source, https://github.com/fmi-faim/metamorph-mda-parser
|
|
8
|
+
Author-email: Jan Eglinger <jan.eglinger@fmi.ch>
|
|
9
|
+
License-Expression: BSD-3-Clause
|
|
10
|
+
License-File: LICENSE.txt
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
19
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
20
|
+
Requires-Python: >=3.8
|
|
21
|
+
Requires-Dist: pandas
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# metamorph-mda-parser
|
|
25
|
+
|
|
26
|
+
[](https://pypi.org/project/metamorph-mda-parser)
|
|
27
|
+
[](https://pypi.org/project/metamorph-mda-parser)
|
|
28
|
+
|
|
29
|
+
-----
|
|
30
|
+
|
|
31
|
+
Light-weight parsing of Metamorph/VisiView Multi Dimensional Acquisition .nd files.
|
|
32
|
+
|
|
33
|
+
For the file format description, see: https://support.moleculardevices.com/s/article/MDA-file-formats
|
|
34
|
+
|
|
35
|
+
**Table of Contents**
|
|
36
|
+
|
|
37
|
+
- [Installation](#installation)
|
|
38
|
+
- [License](#license)
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```console
|
|
43
|
+
pip install metamorph-mda-parser
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
`metamorph-mda-parser` is distributed under the terms of the [BSD-3-Clause](https://spdx.org/licenses/BSD-3-Clause.html) license.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# metamorph-mda-parser
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/metamorph-mda-parser)
|
|
4
|
+
[](https://pypi.org/project/metamorph-mda-parser)
|
|
5
|
+
|
|
6
|
+
-----
|
|
7
|
+
|
|
8
|
+
Light-weight parsing of Metamorph/VisiView Multi Dimensional Acquisition .nd files.
|
|
9
|
+
|
|
10
|
+
For the file format description, see: https://support.moleculardevices.com/s/article/MDA-file-formats
|
|
11
|
+
|
|
12
|
+
**Table of Contents**
|
|
13
|
+
|
|
14
|
+
- [Installation](#installation)
|
|
15
|
+
- [License](#license)
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```console
|
|
20
|
+
pip install metamorph-mda-parser
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## License
|
|
24
|
+
|
|
25
|
+
`metamorph-mda-parser` is distributed under the terms of the [BSD-3-Clause](https://spdx.org/licenses/BSD-3-Clause.html) license.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling", "hatch-vcs"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "metamorph-mda-parser"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = 'Light-weight parsing of Metamorph/VisiView .nd files.'
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = "BSD-3-Clause"
|
|
12
|
+
keywords = []
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Jan Eglinger", email = "jan.eglinger@fmi.ch" },
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Programming Language :: Python",
|
|
19
|
+
"Programming Language :: Python :: 3.8",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
25
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"pandas",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Documentation = "https://github.com/fmi-faim/metamorph-mda-parser#readme"
|
|
33
|
+
Issues = "https://github.com/fmi-faim/metamorph-mda-parser/issues"
|
|
34
|
+
Source = "https://github.com/fmi-faim/metamorph-mda-parser"
|
|
35
|
+
|
|
36
|
+
[tool.hatch.version]
|
|
37
|
+
source = "vcs"
|
|
38
|
+
|
|
39
|
+
[tool.hatch.envs.default]
|
|
40
|
+
dependencies = [
|
|
41
|
+
"coverage[toml]>=6.5",
|
|
42
|
+
"pytest",
|
|
43
|
+
]
|
|
44
|
+
[tool.hatch.envs.default.scripts]
|
|
45
|
+
test = "pytest {args:tests}"
|
|
46
|
+
test-cov = "coverage run -m pytest {args:tests}"
|
|
47
|
+
cov-report = [
|
|
48
|
+
"- coverage combine",
|
|
49
|
+
"coverage report",
|
|
50
|
+
]
|
|
51
|
+
cov = [
|
|
52
|
+
"test-cov",
|
|
53
|
+
"cov-report",
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
[[tool.hatch.envs.all.matrix]]
|
|
57
|
+
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
|
58
|
+
|
|
59
|
+
[tool.hatch.envs.types]
|
|
60
|
+
dependencies = [
|
|
61
|
+
"mypy>=1.0.0",
|
|
62
|
+
]
|
|
63
|
+
[tool.hatch.envs.types.scripts]
|
|
64
|
+
check = "mypy --install-types --non-interactive {args:src/metamorph_mda_parser tests}"
|
|
65
|
+
|
|
66
|
+
[tool.coverage.run]
|
|
67
|
+
source_pkgs = ["metamorph_mda_parser", "tests"]
|
|
68
|
+
branch = true
|
|
69
|
+
parallel = true
|
|
70
|
+
omit = [
|
|
71
|
+
"src/metamorph_mda_parser/__about__.py",
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
[tool.coverage.paths]
|
|
75
|
+
metamorph_mda_parser = ["src/metamorph_mda_parser", "*/metamorph-mda-parser/src/metamorph_mda_parser"]
|
|
76
|
+
tests = ["tests", "*/metamorph-mda-parser/tests"]
|
|
77
|
+
|
|
78
|
+
[tool.coverage.report]
|
|
79
|
+
exclude_lines = [
|
|
80
|
+
"no cov",
|
|
81
|
+
"if __name__ == .__main__.:",
|
|
82
|
+
"if TYPE_CHECKING:",
|
|
83
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Callable, Literal
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
import pandas as pd
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class NdInfo:
|
|
12
|
+
path: Path
|
|
13
|
+
name: str
|
|
14
|
+
version: Literal["1.0", "2.0"]
|
|
15
|
+
description: str
|
|
16
|
+
do_timelapse: bool
|
|
17
|
+
do_stage: bool
|
|
18
|
+
do_wave: bool
|
|
19
|
+
do_z: bool
|
|
20
|
+
stage_positions: list[str]
|
|
21
|
+
wave_names: list[str]
|
|
22
|
+
wave_do_z: list[bool]
|
|
23
|
+
n_timepoints: int
|
|
24
|
+
n_z_steps: int
|
|
25
|
+
z_step_size: float
|
|
26
|
+
wave_in_file_name: bool
|
|
27
|
+
|
|
28
|
+
def __init__(self, path: Path):
|
|
29
|
+
self.path = path
|
|
30
|
+
self.name = path.stem
|
|
31
|
+
self._parse_nd()
|
|
32
|
+
|
|
33
|
+
def _parse_nd(self) -> None:
|
|
34
|
+
with open(self.path) as nd:
|
|
35
|
+
# Version
|
|
36
|
+
self.version = self._parse_line(nd.readline(), "NDInfoFile", self._extract_version)
|
|
37
|
+
self.description = self._parse_line(nd.readline(), "Description", str)
|
|
38
|
+
self.start_time = self._parse_line(nd.readline(), "StartTime1", str)
|
|
39
|
+
# Time lapse
|
|
40
|
+
self.do_timelapse = self._parse_line(nd.readline(), "DoTimelapse", self._parse_bool)
|
|
41
|
+
if self.do_timelapse:
|
|
42
|
+
self.n_timepoints = self._parse_line(nd.readline(), "NTimePoints", int)
|
|
43
|
+
|
|
44
|
+
# Stage positions
|
|
45
|
+
self.do_stage = self._parse_line(nd.readline(), "DoStage", self._parse_bool)
|
|
46
|
+
if self.do_stage:
|
|
47
|
+
n_stage_positions = self._parse_line(nd.readline(), "NStagePositions", int)
|
|
48
|
+
self.stage_positions = []
|
|
49
|
+
for s in range(n_stage_positions):
|
|
50
|
+
self.stage_positions.append(self._parse_line(nd.readline(), f"Stage{s+1}", str))
|
|
51
|
+
|
|
52
|
+
# Wavelengths
|
|
53
|
+
self.do_wave = self._parse_line(nd.readline(), "DoWave", self._parse_bool)
|
|
54
|
+
if self.do_wave:
|
|
55
|
+
n_wavelengths = self._parse_line(nd.readline(), "NWavelengths", int)
|
|
56
|
+
self.wave_names = []
|
|
57
|
+
self.wave_do_z = []
|
|
58
|
+
for w in range(n_wavelengths):
|
|
59
|
+
self.wave_names.append(self._parse_line(nd.readline(), f"WaveName{w+1}", str))
|
|
60
|
+
self.wave_do_z.append(self._parse_line(nd.readline(), f"WaveDoZ{w+1}", self._parse_bool))
|
|
61
|
+
|
|
62
|
+
# Z steps
|
|
63
|
+
self.do_z = self._parse_line(nd.readline(), "DoZSeries", self._parse_bool)
|
|
64
|
+
self.n_z_steps = self._parse_line(nd.readline(), "NZSteps", int)
|
|
65
|
+
self.z_step_size = self._parse_line(nd.readline(), "ZStepSize", float)
|
|
66
|
+
|
|
67
|
+
self.wave_in_file_name = self._parse_line(nd.readline(), "WaveInFileName", self._parse_bool)
|
|
68
|
+
|
|
69
|
+
# End of file
|
|
70
|
+
last_line = nd.readline()
|
|
71
|
+
if last_line.strip(' "\n') != "EndFile":
|
|
72
|
+
message = f"Expected end of file, got: {last_line}"
|
|
73
|
+
raise ValueError(message)
|
|
74
|
+
|
|
75
|
+
def _parse_line(self, line: str, key: str, value_function: Callable):
|
|
76
|
+
tokens = line.split(",")
|
|
77
|
+
if tokens[0].strip(' "') != key:
|
|
78
|
+
message = f"Invalid nd file contents.\n\texpected: {key}\n\tgot: {line}"
|
|
79
|
+
raise ValueError(message)
|
|
80
|
+
return value_function(tokens[1].strip(' "\n'))
|
|
81
|
+
|
|
82
|
+
def _extract_version(self, value: str) -> str:
|
|
83
|
+
return value[8:]
|
|
84
|
+
|
|
85
|
+
def _parse_bool(self, value: str) -> bool:
|
|
86
|
+
return value.lower() == "true"
|
|
87
|
+
|
|
88
|
+
def _wavelengths(self):
|
|
89
|
+
for i, w in enumerate(self.wave_names):
|
|
90
|
+
if self.do_wave:
|
|
91
|
+
yield (
|
|
92
|
+
i,
|
|
93
|
+
w,
|
|
94
|
+
f"_w{i+1}{w}" if self.wave_in_file_name else "",
|
|
95
|
+
self.wave_do_z[i],
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
def _stage_positions(self):
|
|
99
|
+
for s, s_name in enumerate(self.stage_positions):
|
|
100
|
+
if self.do_stage:
|
|
101
|
+
yield s, s_name, f"_s{s+1}"
|
|
102
|
+
|
|
103
|
+
def _timepoints(self):
|
|
104
|
+
if self.do_timelapse:
|
|
105
|
+
for t in range(self.n_timepoints):
|
|
106
|
+
yield t, f"_t{t+1}"
|
|
107
|
+
|
|
108
|
+
def _get_path_channel_position_time(self):
|
|
109
|
+
for w_idx, w_name, w, has_z in list(self._wavelengths()) or [("", self.do_z)]:
|
|
110
|
+
for s_idx, s_name, s in list(self._stage_positions()) or [(0, None, "")]:
|
|
111
|
+
for t_idx, t in list(self._timepoints()) or [(0, "")]:
|
|
112
|
+
yield (
|
|
113
|
+
self.path.parent / (self.name + w + s + t + (".stk" if has_z else ".tif")),
|
|
114
|
+
w_idx,
|
|
115
|
+
w_name,
|
|
116
|
+
s_idx,
|
|
117
|
+
s_name,
|
|
118
|
+
t_idx,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
def get_files(self) -> pd.DataFrame:
|
|
122
|
+
return pd.DataFrame.from_records(
|
|
123
|
+
self._get_path_channel_position_time(),
|
|
124
|
+
columns=[
|
|
125
|
+
"path",
|
|
126
|
+
"channel",
|
|
127
|
+
"channel_name",
|
|
128
|
+
"position",
|
|
129
|
+
"position_name",
|
|
130
|
+
"time",
|
|
131
|
+
],
|
|
132
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"NDInfoFile", Version 1.0
|
|
2
|
+
"Description", File recreated from images.
|
|
3
|
+
"StartTime1", 20240209 16:25:29.500
|
|
4
|
+
"DoTimelapse", TRUE
|
|
5
|
+
"NTimePoints", 361
|
|
6
|
+
"DoStage", TRUE
|
|
7
|
+
"NStagePositions", 75
|
|
8
|
+
"Stage1", "1"
|
|
9
|
+
"Stage2", "2"
|
|
10
|
+
"Stage3", "3"
|
|
11
|
+
"Stage4", "4"
|
|
12
|
+
"Stage5", "5"
|
|
13
|
+
"Stage6", "6"
|
|
14
|
+
"Stage7", "7"
|
|
15
|
+
"Stage8", "8"
|
|
16
|
+
"Stage9", "9"
|
|
17
|
+
"Stage10", "10"
|
|
18
|
+
"Stage11", "11"
|
|
19
|
+
"Stage12", "12"
|
|
20
|
+
"Stage13", "13"
|
|
21
|
+
"Stage14", "14"
|
|
22
|
+
"Stage15", "15"
|
|
23
|
+
"Stage16", "16"
|
|
24
|
+
"Stage17", "17"
|
|
25
|
+
"Stage18", "18"
|
|
26
|
+
"Stage19", "19"
|
|
27
|
+
"Stage20", "20"
|
|
28
|
+
"Stage21", "21"
|
|
29
|
+
"Stage22", "22"
|
|
30
|
+
"Stage23", "23"
|
|
31
|
+
"Stage24", "24"
|
|
32
|
+
"Stage25", "25"
|
|
33
|
+
"Stage26", "26"
|
|
34
|
+
"Stage27", "27"
|
|
35
|
+
"Stage28", "28"
|
|
36
|
+
"Stage29", "29"
|
|
37
|
+
"Stage30", "30"
|
|
38
|
+
"Stage31", "31"
|
|
39
|
+
"Stage32", "32"
|
|
40
|
+
"Stage33", "33"
|
|
41
|
+
"Stage34", "34"
|
|
42
|
+
"Stage35", "35"
|
|
43
|
+
"Stage36", "36"
|
|
44
|
+
"Stage37", "37"
|
|
45
|
+
"Stage38", "38"
|
|
46
|
+
"Stage39", "39"
|
|
47
|
+
"Stage40", "40"
|
|
48
|
+
"Stage41", "41"
|
|
49
|
+
"Stage42", "42"
|
|
50
|
+
"Stage43", "43"
|
|
51
|
+
"Stage44", "44"
|
|
52
|
+
"Stage45", "45"
|
|
53
|
+
"Stage46", "46"
|
|
54
|
+
"Stage47", "47"
|
|
55
|
+
"Stage48", "48"
|
|
56
|
+
"Stage49", "49"
|
|
57
|
+
"Stage50", "50"
|
|
58
|
+
"Stage51", "51"
|
|
59
|
+
"Stage52", "52"
|
|
60
|
+
"Stage53", "53"
|
|
61
|
+
"Stage54", "54"
|
|
62
|
+
"Stage55", "55"
|
|
63
|
+
"Stage56", "56"
|
|
64
|
+
"Stage57", "57"
|
|
65
|
+
"Stage58", "58"
|
|
66
|
+
"Stage59", "59"
|
|
67
|
+
"Stage60", "60"
|
|
68
|
+
"Stage61", "61"
|
|
69
|
+
"Stage62", "62"
|
|
70
|
+
"Stage63", "63"
|
|
71
|
+
"Stage64", "64"
|
|
72
|
+
"Stage65", "65"
|
|
73
|
+
"Stage66", "66"
|
|
74
|
+
"Stage67", "67"
|
|
75
|
+
"Stage68", "68"
|
|
76
|
+
"Stage69", "69"
|
|
77
|
+
"Stage70", "70"
|
|
78
|
+
"Stage71", "71"
|
|
79
|
+
"Stage72", "72"
|
|
80
|
+
"Stage73", "73"
|
|
81
|
+
"Stage74", "74"
|
|
82
|
+
"Stage75", "75"
|
|
83
|
+
"DoWave", TRUE
|
|
84
|
+
"NWavelengths", 2
|
|
85
|
+
"WaveName1", "BF-488-Cam1"
|
|
86
|
+
"WaveDoZ1", TRUE
|
|
87
|
+
"WaveName2", "488-BF-Cam0"
|
|
88
|
+
"WaveDoZ2", TRUE
|
|
89
|
+
"DoZSeries", TRUE
|
|
90
|
+
"NZSteps", 25
|
|
91
|
+
"ZStepSize", 2.00
|
|
92
|
+
"WaveInFileName", TRUE
|
|
93
|
+
"EndFile"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"NDInfoFile", Version 1.0
|
|
2
|
+
"Description", File recreated from images.
|
|
3
|
+
"StartTime1", 20230922 12:33:22.559
|
|
4
|
+
"DoTimelapse", FALSE
|
|
5
|
+
"DoStage", TRUE
|
|
6
|
+
"NStagePositions", 4
|
|
7
|
+
"Stage1", "Position1"
|
|
8
|
+
"Stage2", "Position2"
|
|
9
|
+
"Stage3", "Position3"
|
|
10
|
+
"Stage4", "Position4"
|
|
11
|
+
"DoWave", TRUE
|
|
12
|
+
"NWavelengths", 4
|
|
13
|
+
"WaveName1", "Conf640"
|
|
14
|
+
"WaveDoZ1", TRUE
|
|
15
|
+
"WaveName2", "Conf561"
|
|
16
|
+
"WaveDoZ2", TRUE
|
|
17
|
+
"WaveName3", "Conf488"
|
|
18
|
+
"WaveDoZ3", TRUE
|
|
19
|
+
"WaveName4", "Conf405"
|
|
20
|
+
"WaveDoZ4", TRUE
|
|
21
|
+
"DoZSeries", TRUE
|
|
22
|
+
"NZSteps", 42
|
|
23
|
+
"ZStepSize", 3
|
|
24
|
+
"WaveInFileName", TRUE
|
|
25
|
+
"EndFile"
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from metamorph_mda_parser.nd import NdInfo
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@pytest.fixture
|
|
9
|
+
def sample_4ch_4pos():
|
|
10
|
+
return Path("tests/resources/sample_4ch_4pos.nd")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@pytest.fixture
|
|
14
|
+
def sample_2ch_75pos_361t():
|
|
15
|
+
return Path("tests/resources/sample_2ch_75pos_361t.nd")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_sample_4ch_4pos(sample_4ch_4pos):
|
|
19
|
+
nd_info = NdInfo(sample_4ch_4pos)
|
|
20
|
+
|
|
21
|
+
assert nd_info.version == "1.0"
|
|
22
|
+
assert nd_info.description == "File recreated from images."
|
|
23
|
+
assert not nd_info.do_timelapse
|
|
24
|
+
assert nd_info.do_stage
|
|
25
|
+
assert len(nd_info.stage_positions) == 4
|
|
26
|
+
assert nd_info.do_wave
|
|
27
|
+
assert len(nd_info.wave_names) == 4
|
|
28
|
+
assert nd_info.do_z
|
|
29
|
+
assert nd_info.n_z_steps == 42
|
|
30
|
+
assert nd_info.z_step_size == 3.0
|
|
31
|
+
assert nd_info.wave_in_file_name
|
|
32
|
+
assert nd_info.wave_names == ["Conf640", "Conf561", "Conf488", "Conf405"]
|
|
33
|
+
|
|
34
|
+
files = nd_info.get_files()
|
|
35
|
+
|
|
36
|
+
assert len(files) == 16
|
|
37
|
+
assert files["channel"].unique().tolist() == [0, 1, 2, 3]
|
|
38
|
+
assert files["channel_name"].unique().tolist() == nd_info.wave_names
|
|
39
|
+
assert files["position"].unique().tolist() == [0, 1, 2, 3]
|
|
40
|
+
assert files["position_name"].unique().tolist() == [
|
|
41
|
+
"Position1",
|
|
42
|
+
"Position2",
|
|
43
|
+
"Position3",
|
|
44
|
+
"Position4",
|
|
45
|
+
]
|
|
46
|
+
assert files["time"].unique().tolist() == [0]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_sample_2ch_75pos_361t(sample_2ch_75pos_361t):
|
|
50
|
+
nd_info = NdInfo(sample_2ch_75pos_361t)
|
|
51
|
+
|
|
52
|
+
assert nd_info.version == "1.0"
|
|
53
|
+
assert nd_info.description == "File recreated from images."
|
|
54
|
+
assert nd_info.do_timelapse
|
|
55
|
+
assert nd_info.n_timepoints == 361
|
|
56
|
+
assert nd_info.do_stage
|
|
57
|
+
assert len(nd_info.stage_positions) == 75
|
|
58
|
+
assert nd_info.do_wave
|
|
59
|
+
assert len(nd_info.wave_names) == 2
|
|
60
|
+
assert nd_info.do_z
|
|
61
|
+
assert nd_info.n_z_steps == 25
|
|
62
|
+
assert nd_info.z_step_size == 2.0
|
|
63
|
+
assert nd_info.wave_in_file_name
|
|
64
|
+
assert nd_info.wave_names == ["BF-488-Cam1", "488-BF-Cam0"]
|
|
65
|
+
|
|
66
|
+
files = nd_info.get_files()
|
|
67
|
+
|
|
68
|
+
assert len(files) == 54150
|