Skip to content

Commit

Permalink
Merge pull request #21 from neuro-ml/fix-starter-example
Browse files Browse the repository at this point in the history
remove bad formatting
  • Loading branch information
maxme1 authored Jan 27, 2023
2 parents 9e918a3 + 0a51767 commit 46caa03
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 28 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ on:
release:
types: [ released ]

env:
MODULE_NAME: dicom_csv

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.9

Expand All @@ -24,7 +27,7 @@ jobs:
run: |
RELEASE=${{ steps.get_version.outputs.version-without-v }}
VERSION=$(python -c "from pathlib import Path; import runpy; folder, = {d.parent for d in Path().resolve().glob('*/__init__.py') if d.parent.is_dir() and (d.parent / '__version__.py').exists()}; print(runpy.run_path(folder / '__version__.py')['__version__'])")
MATCH=$(pip index versions dicom-csv | grep "Available versions:" | grep $VERSION) || echo
MATCH=$(pip index versions $MODULE_NAME | grep "Available versions:" | grep $VERSION) || echo
echo $MATCH
if [ "$GITHUB_BASE_REF" = "master" ] && [ "$MATCH" != "" ]; then echo "Version $VERSION already present" && exit 1; fi
if [ "$VERSION" != "$RELEASE" ]; then echo "$VERSION vs $RELEASE" && exit 1; fi
Expand Down
20 changes: 13 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
name: Python package

on: [ push, pull_request ]
on: [ pull_request ]

env:
MODULE_NAME: dicom_csv

jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ 3.6, 3.7, 3.8, 3.9 ]
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10', '3.11' ]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Check the version and build the package
- name: Check the version
if: "! github.event.pull_request.head.repo.fork "
run: |
VERSION=$(python -c "from pathlib import Path; import runpy; folder, = {d.parent for d in Path().resolve().glob('*/__init__.py') if d.parent.is_dir() and (d.parent / '__version__.py').exists()}; print(runpy.run_path(folder / '__version__.py')['__version__'])")
MATCH=$(pip index versions dicom-csv | grep "Available versions:" | grep $VERSION) || echo
MATCH=$(pip index versions $MODULE_NAME | grep "Available versions:" | grep $VERSION) || echo
echo $MATCH
if [ "$GITHUB_BASE_REF" = "master" ] && [ "$MATCH" != "" ]; then exit 1; fi
- name: Build the package
run: |
python setup.py sdist
- name: Install
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ pip install -e .
from a series of dicom files (each containing 2D image)

```python
>>> from dicom_csv import join_tree, order_series, stack_images
>>> from pydicom import dcmread
>>> from pathlib import Path
>>>
>>> # 1. Collect metadata from all dicom files
>>> folder = Path('/path/to/folder/')
>>> meta = join_tree(folder, verbose=2)
>>>
>>> # 2. Select series to load
>>> uid = '...' # unique identifier of a series you want to load,
>>> # you could list them by `meta.SeriesInstanceUID.unique()`
>>> series = meta.query("SeriesInstanceUID==@uid")
>>>
>>> # 3. Read files & combine them into a single volume
>>> images2d = [dcmread(folder / row[1].PathToFolder / row[1].FileName) for row in series.iterrows()]
>>> image3d = stack_images(order_series(images2d))
from dicom_csv import join_tree, order_series, stack_images
from pydicom import dcmread
from pathlib import Path

# 1. Collect metadata from all dicom files
folder = Path('/path/to/folder/')
meta = join_tree(folder, verbose=2)

# 2. Select series to load
uid = '...' # unique identifier of a series you want to load,
# you could list them by `meta.SeriesInstanceUID.unique()`
series = meta.query("SeriesInstanceUID==@uid")

# 3. Read files & combine them into a single volume
images2d = [dcmread(folder / row[1].PathToFolder / row[1].FileName) for row in series.iterrows()]
image3d = stack_images(order_series(images2d))
```

# Documentation
Expand Down
2 changes: 1 addition & 1 deletion dicom_csv/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.2.5'
__version__ = '0.2.6'
2 changes: 1 addition & 1 deletion dicom_csv/spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def get_image_size(series: Series) -> Tuple[int, int, int]:
rows = get_common_tag(series, 'Rows')
columns = get_common_tag(series, 'Columns')
slices = len(series)
return rows, columns, slices
return int(rows), int(columns), slices


def drop_duplicated_slices(series: Series, tolerance_hu=1) -> Series:
Expand Down

0 comments on commit 46caa03

Please sign in to comment.