Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from io import StringIO

import pandas as pd

from allotropy.exceptions import AllotropeConversionError, AllotropeParsingError
Expand All @@ -10,9 +12,29 @@ class NucleoviewReader:

@classmethod
def read(cls, contents: IOType) -> pd.DataFrame:
df = read_csv(
contents, sep="[;,]+", engine="python", skipinitialspace=True, index_col=0
)
content = contents.read()
content_str = content.decode("UTF-8") if isinstance(content, bytes) else content
separators = [":\t", "[;,]+"]
last_error = None

for sep in separators:
try:
df = read_csv(
StringIO(content_str),
sep=sep,
engine="python",
skipinitialspace=True,
index_col=0,
)
if df.shape[1] >= 1:
break
except AllotropeParsingError as e:
last_error = e
continue
else:
if last_error:
raise last_error

try:
df = df[:-1].dropna(axis="index", how="all").T
except KeyError as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def _converted_value_or_none(key: str) -> float | None:
Measurement(
measurement_identifier=random_uuid_str(),
timestamp=timestamp or DEFAULT_EPOCH_TIMESTAMP,
sample_identifier=data[str, "Image"].split("-")[3],
sample_identifier=data.get(str, "Sample ID")
or data[str, "Image"].split("-")[3],
cell_density_dilution_factor=data.get(float, "Multiplication factor"),
viability=data[float, "Viability (%)"],
# Cell counts are measured in cells/mL, but reported in millions of cells/mL
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Source ID: 99999999-00009
Time (UTC): 1999-09-99 09:49:29
Sample ID: 1111_viability count new 99x_pass 99
Protocol: Count & Viability; 1.49
Software version: 9.9.9.99
Secure Mode status: Enable
Signed by:
Sample Media: Via2-Cassette
User: gih
Operator: gih
Instrument: S/N:99999999999
Tags:
Comments:
Total (cells/ml): 1.12E+06
Live (cells/ml): 9.28E+05
Dead (cells/ml): 1.90E+05
Viability (%): 83.0
Diameter (um): 9.7
Aggregates (%): 0.0
Debris Index: 50
Dilution Factor: 10
Status: OK
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"$asm.manifest": "http://purl.allotrope.org/manifests/cell-counting/REC/2024/09/cell-counting.manifest",
"cell counting aggregate document": {
"cell counting document": [
{
"measurement aggregate document": {
"measurement document": [
{
"device control aggregate document": {
"device control document": [
{
"device type": "dark field imager (cell counter)",
"detection type": "dark field"
}
]
},
"measurement identifier": "CHEMOMETEC_NUCLEOVIEW_TEST_ID_0",
"measurement time": "1970-01-01T00:00:00+00:00",
"processed data aggregate document": {
"processed data document": [
{
"viability (cell counter)": {
"value": 83.0,
"unit": "%"
},
"viable cell density (cell counter)": {
"value": 0.928,
"unit": "10^6 cells/mL"
},
"total cell density (cell counter)": {
"value": 1.12,
"unit": "10^6 cells/mL"
},
"dead cell density (cell counter)": {
"value": 0.19,
"unit": "10^6 cells/mL"
}
}
]
},
"sample document": {
"sample identifier": "1111_viability count new 99x_pass 99"
},
"custom information document": {
"User": "gih",
"Secure Mode status": "Enable",
"Sample Media": "Via2-Cassette",
"Software version": "9.9.9.99",
"Time (UTC)": "1999-09-99 09:49:29",
"Debris Index": 50.0,
"Instrument": "S/N:99999999999",
"Protocol": "Count & Viability; 1.49",
"Aggregates (%)": 0.0,
"Dilution Factor": 10.0,
"Diameter (um)": 9.7
}
}
]
},
"analyst": "gih"
}
],
"data system document": {
"ASM file identifier": "chemometec_nucleoview_example08.json",
"data system instance identifier": "N/A",
"file name": "chemometec_nucleoview_example08.csv",
"UNC path": "tests/parsers/chemometec_nucleoview/testdata/chemometec_nucleoview_example08.csv",
"ASM converter name": "allotropy_chemometec_nucleoview",
"ASM converter version": "0.1.93",
"software name": "NucleoView"
},
"device system document": {
"model number": "NucleoCounter NC-200"
}
}
}
Loading