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
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ add:

# copies metadata to path included in pypet2bids project to enable packaging of those files w/ poetry
buildpackage:
@cp -R metadata/ pypet2bids/pypet2bids/metadata
@cp pypet2bids/pyproject.toml pypet2bids/pypet2bids/pyproject.toml
@rm -rf pypet2bids/dist
@cd pypet2bids && poetry lock && poetry build
Expand Down
235 changes: 111 additions & 124 deletions pypet2bids/poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pypet2bids/pypet2bids/dcm2niix4pet.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ def run_dcm2niix(self):
created_path,
check_for_missing,
dicom_header,
dicom2bids_json=metadata_dictionaries["dicom2bids.json"],
dicom2bids_json=metadata_dictionaries["dicom2bids"],
**self.additional_arguments,
)

Expand Down
58 changes: 35 additions & 23 deletions pypet2bids/pypet2bids/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
import argparse
from typing import Union
from platform import system
import importlib

try:
import metadata
except ImportError:
from pypet2bids import metadata

parent_dir = pathlib.Path(__file__).parent.resolve()
project_dir = parent_dir.parent.parent
Expand All @@ -55,14 +61,12 @@
)

# load bids schema
bids_schema_path = os.path.join(metadata_dir, "schema.json")
schema = json.load(open(bids_schema_path, "r"))
schema = metadata.schema

# putting these paths here as they are reused in dcm2niix4pet.py, update_json_pet_file.py, and ecat.py
module_folder = Path(__file__).parent.resolve()
python_folder = module_folder.parent
pet2bids_folder = python_folder.parent
metadata_folder = os.path.join(pet2bids_folder, "metadata")

loggers = {}

Expand Down Expand Up @@ -316,27 +320,37 @@ def load_vars_from_config(

def get_version():
"""
Gets the version of this software from the toml file
:return: version number from pyproject.toml
Gets the version of this software
:return: version number
"""
# this scripts directory path
scripts_dir = pathlib.Path(os.path.dirname(__file__))

try:
# if this is bundled as a package look next to this file for the pyproject.toml
toml_path = os.path.join(scripts_dir, "pyproject.toml")
with open(toml_path, "r") as infile:
tomlfile = toml.load(infile)
except FileNotFoundError:
# when in development the toml file with the version is 2 directories above (e.g. where it should actually live)
toml_dir = scripts_dir.parent
toml_path = os.path.join(toml_dir, "pyproject.toml")
with open(toml_path, "r") as infile:
tomlfile = toml.load(infile)

attrs = tomlfile.get("tool", {})
poetry = attrs.get("poetry", {})
version = poetry.get("version", "")
# first try using importlib.metadata.version to determine version

version = importlib.metadata.version("pypet2bids")

if not version:
tomlfile = {}

try:
# if this is bundled as a package look next to this file for the pyproject.toml
toml_path = os.path.join(scripts_dir, "pyproject.toml")
with open(toml_path, "r") as infile:
tomlfile = toml.load(infile)
except FileNotFoundError:
# when in development the toml file with the version is 2 directories above (e.g. where it should actually live)
try:
toml_dir = scripts_dir.parent
toml_path = os.path.join(toml_dir, "pyproject.toml")
with open(toml_path, "r") as infile:
tomlfile = toml.load(infile)
except FileNotFoundError:
pass

attrs = tomlfile.get("tool", {})
poetry = attrs.get("poetry", {})
version = poetry.get("version", "")

return version

Expand Down Expand Up @@ -820,9 +834,7 @@ def get_recon_method(ReconstructionMethodString: str) -> dict:
dimension = re.search(search_criteria, ReconMethodName)[0]

# doing some more manipulation of the recon method name to expand it from not so helpful acronyms
possible_names = load_pet_bids_requirements_json(pet_reconstruction_metadata_json)[
"reconstruction_names"
]
possible_names = metadata.PET_reconstruction_methods.get("reconstruction_names", [])

# we want to sort the possible names by longest first that we don't break up an acronym prematurely
sorted_df = pandas.DataFrame(possible_names).sort_values(
Expand Down
Loading
Loading