# Classification Toolkit
The main documentation for the classification-toolkit can be found at the
[fw-classification
Documentation](https://flywheel-io.gitlab.io/scientific-solutions/lib/fw-classification/)
Classification toolkit is a library that can act on arbitrary metadata in the
form of JSON, with a declarative set of rules. The main use case for this
library is for classification of medical imaging files based on their
metadata, for example, the `SeriesDescription` tag in a DICOM file.
## Install
`poetry add fw-classification`, or with optional dependencies
`poetry add fw-classification -E all`.
## Run classification via cli
<!-- markdownlint-disable line-length -->
```bash
~/ ➜ classify run ./fw_classification/profiles/main.yml ~/Downloads/example.dicom.zip -a dicom
fw_classification: Block mr_file result: True
fw_classification: Block set_modality result: True
fw_classification: Block set_classification_from_acquisition_label_or_series_description result: True
fw_classification: Block set_contrast_from_acquisition_label_or_series_description result: False
fw_classification: Block add_features_from_acquisition_label_or_series_description result: False
fw_classification: Block add_measurement_from_acquisition_label_or_series_description result: False
fw_classification: Block add_intent_from_acquisition_label_or_series_description result: False
{
"file": {
"info": {
"header": {
"dicom": {
"FileMetaInformationGroupLength": 216,
"WindowWidth": 199.0,
... # Many more tags
"dBdt": 0.0
}
}
},
"type": "dicom",
"modality": "MR",
"classification": {
"Intent": [
"Structural"
],
"Measurement": [
"T1"
]
}
}
}
```
<!-- markdownlint-enable line-length -->
## Run via python
```python
from fw_classification.classify import run_classification
import json
input_data = {}
with open('/path/to/input','r') as fp:
input_data = json.load(fp)
result, out_data = run_classification('MR_classifier', input_data)
```
Out:
```bash
~/ ➜ python test.py
{
"file": {
"info": {
"header": {
"dicom": {
"FileMetaInformationGroupLength": 216,
... # Many more tags
"WindowWidth": 199.0,
"dBdt": 0.0
}
}
},
"type": "dicom",
"modality": "MR",
"classification": {
"Intent": [
"Structural"
],
"Measurement": [
"T1"
]
}
}
}
```
## Development
Install the project using poetry (requires poetry > 1.2.0b1), enable plugin and
pre-commit:
```bash
poetry install --extras "all"
pre-commit install
```
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/flywheel-io/public/classification-toolkit",
"name": "fw-classification",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Flywheel",
"author_email": "support@flywheel.io",
"download_url": null,
"platform": null,
"description": "# Classification Toolkit\n\nThe main documentation for the classification-toolkit can be found at the\n[fw-classification\nDocumentation](https://flywheel-io.gitlab.io/scientific-solutions/lib/fw-classification/)\n\nClassification toolkit is a library that can act on arbitrary metadata in the\nform of JSON, with a declarative set of rules. The main use case for this\nlibrary is for classification of medical imaging files based on their\nmetadata, for example, the `SeriesDescription` tag in a DICOM file.\n\n## Install\n\n`poetry add fw-classification`, or with optional dependencies\n`poetry add fw-classification -E all`.\n\n## Run classification via cli\n\n<!-- markdownlint-disable line-length -->\n```bash\n~/ \u279c classify run ./fw_classification/profiles/main.yml ~/Downloads/example.dicom.zip -a dicom\nfw_classification: Block mr_file result: True\nfw_classification: Block set_modality result: True\nfw_classification: Block set_classification_from_acquisition_label_or_series_description result: True\nfw_classification: Block set_contrast_from_acquisition_label_or_series_description result: False\nfw_classification: Block add_features_from_acquisition_label_or_series_description result: False\nfw_classification: Block add_measurement_from_acquisition_label_or_series_description result: False\nfw_classification: Block add_intent_from_acquisition_label_or_series_description result: False\n{\n \"file\": {\n \"info\": {\n \"header\": {\n \"dicom\": {\n \"FileMetaInformationGroupLength\": 216,\n \"WindowWidth\": 199.0,\n ... # Many more tags\n \"dBdt\": 0.0\n }\n }\n },\n \"type\": \"dicom\",\n \"modality\": \"MR\",\n \"classification\": {\n \"Intent\": [\n \"Structural\"\n ],\n \"Measurement\": [\n \"T1\"\n ]\n }\n }\n}\n```\n<!-- markdownlint-enable line-length -->\n\n## Run via python\n\n```python\nfrom fw_classification.classify import run_classification\nimport json\n\ninput_data = {}\nwith open('/path/to/input','r') as fp:\n input_data = json.load(fp)\n\nresult, out_data = run_classification('MR_classifier', input_data)\n```\n\nOut:\n\n```bash\n~/ \u279c python test.py\n{\n \"file\": {\n \"info\": {\n \"header\": {\n \"dicom\": {\n \"FileMetaInformationGroupLength\": 216,\n ... # Many more tags\n \"WindowWidth\": 199.0,\n \"dBdt\": 0.0\n }\n }\n },\n \"type\": \"dicom\",\n \"modality\": \"MR\",\n \"classification\": {\n \"Intent\": [\n \"Structural\"\n ],\n \"Measurement\": [\n \"T1\"\n ]\n }\n }\n}\n```\n\n## Development\n\nInstall the project using poetry (requires poetry > 1.2.0b1), enable plugin and\npre-commit:\n\n```bash\npoetry install --extras \"all\"\npre-commit install\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Flywheel classification toolkit.",
"version": "0.4.5",
"project_urls": {
"Homepage": "https://gitlab.com/flywheel-io/public/classification-toolkit",
"Repository": "https://gitlab.com/flywheel-io/public/classification-toolkit"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9291904a00f0c0d13891b3495eb82e39ba250fadc085b82dd400ffe91dc58829",
"md5": "ddc007c0c423ea9f81ad4c33a0f528f8",
"sha256": "178575fdd6f9ff0415ad4e370f496847aca52b1b3ae3989f666f23f77e0fad5a"
},
"downloads": -1,
"filename": "fw_classification-0.4.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ddc007c0c423ea9f81ad4c33a0f528f8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 30715,
"upload_time": "2024-09-04T22:05:33",
"upload_time_iso_8601": "2024-09-04T22:05:33.232996Z",
"url": "https://files.pythonhosted.org/packages/92/91/904a00f0c0d13891b3495eb82e39ba250fadc085b82dd400ffe91dc58829/fw_classification-0.4.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-04 22:05:33",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "flywheel-io",
"gitlab_project": "public",
"lcname": "fw-classification"
}