Skip to content

Commit

Permalink
updates pre-commit flake-8
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoerdk committed Nov 20, 2023
1 parent 57d36fc commit 76617ba
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Expand Up @@ -12,8 +12,8 @@ repos:
hooks:
- id: black
language: python
- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
exclude: dicomtrolley/xml_templates.py
Expand All @@ -29,6 +29,6 @@ repos:
hooks:
- id: mypy
additional_dependencies:
- pydantic
- mypy
- types-requests
- types-Jinja2
34 changes: 30 additions & 4 deletions examples/generate_dicom_data.py
@@ -1,3 +1,4 @@
import uuid
from pathlib import Path

from dicomgenerator.export import export
Expand All @@ -10,9 +11,11 @@

def generate_some_dicom_files(output_dir):
output_dir.mkdir(parents=True, exist_ok=True)
filenames = [f"dcmfile{x}" for x in range(5)]
filenames = [f"dcmfile{x}" for x in range(5, 10)]
for filename in filenames:
export(dataset=CTDatasetFactory(), path=output_dir / filename)
export(
dataset=CTDatasetFactory(PatientID="patient2"), path=output_dir / filename
)

print(f"Wrote {len(filenames)} files to {output_dir}")

Expand All @@ -31,5 +34,28 @@ def generate_file_with_specifics(output_path):
print(f"Wrote file to {output_path}")


# generate_file_with_specifics(output_path=output_dir / 'dicomfile_m')
generate_some_dicom_files(output_dir)
def generate_dicom_structure(structure, output_dir):
output_dir = Path(output_dir)
output_dir.mkdir(parents=True, exist_ok=True)
count = 0
for patient, studies in structure.items():
for study, seriess in studies.items():
for series in seriess:
for _ in range(2):
count = count + 1
export(
dataset=CTDatasetFactory(
PatientID=patient,
StudyInstanceUID=study,
SeriesInstanceUID=series,
),
path=output_dir / str(uuid.uuid4()),
)

print(f"Wrote {count} files to {output_dir}")


structure = {
"patient1": {"11111.1": ["2222.1", "2222.2"], "11111.2": ["2222.1"]},
"patient2": {"11111.1": ["2222.1"], "11111.2": ["2222.1", "2222.2", "2222.3"]},
}
2 changes: 1 addition & 1 deletion pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dicomgenerator"
version = "0.9.0-alpha.1"
version = "0.9.0"
description = "Generate pydicom datasets and data elements for use in testing"
authors = ["sjoerdk <sjoerd.kerkstra@radboudumc.nl>"]
readme = "README.md"
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Expand Up @@ -3,7 +3,6 @@ universal = 1

[mypy]
python_version = 3.8
plugins = pydantic.mypy

warn_return_any=True
strict_optional=True
Expand Down

0 comments on commit 76617ba

Please sign in to comment.