Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/IPASC/PACFISH
Browse files Browse the repository at this point in the history
# Conflicts:
#	pacfish/iohandler/file_reader.py
#	pacfish_matlab/@kwave_adapter/kwave_adapter.m
  • Loading branch information
jgroehl committed Feb 24, 2023
2 parents a59788c + f5e8dfb commit 4dee0db
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 27 deletions.
16 changes: 1 addition & 15 deletions .github/workflows/continuous-integration-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Test PACFISH

on:
push:
branches: [ main ]
branches: [ main, release ]
pull_request:
branches: [ main ]

Expand Down Expand Up @@ -56,17 +56,3 @@ jobs:
pip install
build
--user
- name: Build a binary wheel and a source tarball
if: github.repository == 'IPASC/PACFISH' && matrix.python-version == 3.9 && matrix.os == 'ubuntu-latest'
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish to PyPI
if: github.repository == 'IPASC/PACFISH' && matrix.python-version == 3.9 && matrix.os == 'ubuntu-latest'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI }}
57 changes: 57 additions & 0 deletions .github/workflows/release_integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This workflow will install Python dependencies, run unit_tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Test PACFISH

on:
push:
branches: [release ]

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
python-version: ["3.9"]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
python -m pip install -r requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest --cov=pacfish --cov-report=xml --cov-report=term-missing
coverage xml
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI }}
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ people that have contributed to this project.

| Name | Institution | Contributions |
| ---- | --- | ------------- |
| Ben Cox | University College London | MATLAB API |
| Kris Dreher | German Cancer Research Center | IO Handling |
| Janek Gröhl | University of Cambridge | General Maintenance; Python API |
| Lina Hacker | University of Cambridge | Python API |
| François Varray | Creatis, Université de Lyon | MATLAB API |
| Jeffrey Sackey | University College London | MATLAB API |
| Lawrence Yip | Lawson Health Research Institute | Adapter Implementation, Bug Fixing |

# How to contribute
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.3
0.4.5
23 changes: 14 additions & 9 deletions pacfish/visualize_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def visualize_device(device_dictionary: dict, save_path: str = None, title: str
Optional parameter whether the figure legend should be shown (default: True)
"""

MARGIN = 0.001

def define_boundary_values(_device_dictionary: dict):
mins = np.ones(3) * 100000
maxs = np.ones(3) * -100000
Expand Down Expand Up @@ -59,17 +61,20 @@ def define_boundary_values(_device_dictionary: dict):
if fov[2 * i + 1] > maxs[i]:
maxs[i] = fov[2 * i + 1]

MARGIN = 0.001
maxs += MARGIN
mins -= MARGIN
return mins, maxs

def add_arbitrary_plane(_device_dictionary: dict, _mins, _maxs, _axes, _draw_axis):
_draw_axis.set_xlim(_mins[_axes[0]], _maxs[_axes[0]])
_draw_axis.set_ylim(_maxs[_axes[1]], _mins[_axes[1]])
x_ticks = np.asarray(np.round(np.linspace(_mins[_axes[0]] + MARGIN, _maxs[_axes[0]] - MARGIN, 5), decimals=4))
y_ticks = np.asarray(np.round(np.linspace(_mins[_axes[1]] + MARGIN, _maxs[_axes[1]] - MARGIN, 5), decimals=4))
_draw_axis.set_xticks(x_ticks, x_ticks*100)
_draw_axis.set_yticks(y_ticks, y_ticks * 100)
_draw_axis.set_title(f"axes {_axes[0]}/{_axes[1]} projection view")
_draw_axis.set_xlabel(f"{_axes[0]}-axis [m]")
_draw_axis.set_ylabel(f"{_axes[1]}-axis [m]")
_draw_axis.set_xlabel(f"{_axes[0]}-axis [cm]")
_draw_axis.set_ylabel(f"{_axes[1]}-axis [cm]")

fov = _device_dictionary["general"][MetadataDeviceTags.FIELD_OF_VIEW.tag]

Expand All @@ -84,10 +89,10 @@ def add_arbitrary_plane(_device_dictionary: dict, _mins, _maxs, _axes, _draw_axi
_device_dictionary["detectors"][detector][MetadataDeviceTags.DETECTOR_GEOMETRY.tag])

if detector_geometry_type == "CUBOID":
if detector_geometry[_axes[0]] == 0:
detector_geometry[_axes[0]] = 0.0001
if detector_geometry[_axes[1]] == 0:
detector_geometry[_axes[1]] = 0.0001
if detector_geometry[_axes[0]] < 0.001:
detector_geometry[_axes[0]] = 0.001
if detector_geometry[_axes[1]] < 0.001:
detector_geometry[_axes[1]] = 0.001
_draw_axis.add_patch(Rectangle((detector_position[_axes[0]] - detector_geometry[_axes[0]] / 2,
detector_position[_axes[1]] - detector_geometry[_axes[1]] / 2),
detector_geometry[_axes[0]], detector_geometry[_axes[1]], color="blue"))
Expand Down Expand Up @@ -147,8 +152,8 @@ def add_arbitrary_plane(_device_dictionary: dict, _mins, _maxs, _axes, _draw_axi
plt.figure(figsize=(10, 4))
plt.suptitle(title)
ax = plt.subplot(1, num_subplots, 1)
ax.axes.xaxis.set_visible(False)
ax.axes.yaxis.set_visible(False)
# ax.axes.xaxis.set_visible(False)
# ax.axes.yaxis.set_visible(False)
add_arbitrary_plane(device_dictionary, mins, maxs, _axes=(0, 2), _draw_axis=ax)
if not only_show_xz:
ax = plt.subplot(1, num_subplots, 2)
Expand Down
5 changes: 3 additions & 2 deletions pacfish_matlab/@kwave_adapter/kwave_adapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
end

methods

%% Constructor for the api
function obj = kwave_adapter(varargin)
if (nargin<=4)
Expand Down Expand Up @@ -274,8 +274,8 @@
orientation3 = 180 - acosd(costheta3);
% Stores the 3 orientations made as the
% detector orientation

device_struct.detectors.(index).detector_orientation = [orientation1 orientation3 orientation2];

device_struct.detectors.(index).detector_geometry = [elem.length elem.width elem.length];
end
case 3 % 2D with position elements used as detector
Expand Down Expand Up @@ -429,6 +429,7 @@
end
end


if any(obj.fov) % Checks whether FOV was given as an input (was previously checked above)
device_struct.general.field_of_view = obj.fov;
else
Expand Down

0 comments on commit 4dee0db

Please sign in to comment.