Skip to content

Commit

Permalink
directory tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Jun 18, 2024
1 parent ec7a95e commit bf940ca
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
branches: ['**']
tags: ['**']
paths-ignore: ['LICENSE*', 'LICENCE*', 'README.md']
paths-ignore: ['.gitignore', 'LICENSE*', 'LICENCE*', 'README.md', 'SIRF_data_preparation/*']
jobs:
check:
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ tmp*/
errr.txt
info.txt
warn.txt
__pycache__
__pycache__/
*.s
*.hs

Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
'''
Some functions for plotting used in the examples
'''

## CCP SyneRBI Synergistic Image Reconstruction Framework (SIRF)
## Copyright 2020-2021 University College London
##
## This is software developed for the Collaborative Computational
## Project in Synergistic Reconstruction for Biomedical Imaging (formerly CCP PETMR)
## (http://www.ccpsynerbi.ac.uk/).
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
## http://www.apache.org/licenses/LICENSE-2.0
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.

'''Some functions for plotting used in the examples'''
# Licence: Apache-2.0
# Copyright 2020-2021 University College London
import sirf.STIR as PET
import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -50,4 +32,3 @@ def plot_sinogram_profile(prompts, randoms=None, scatter=None, sumaxis=(0,1), se
plt.plot(np.sum(scatter.as_array() + randoms_as_array, axis=sumaxis)[select,:], label='randoms+scatter')
ax.legend()
plt.show()

Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
'''Library of Siemens data preparation utilities.'''

# Author: Ashley Gillman, Kris Thielemans, Evgueni Ovtchinnikov
# Authors: Ashley Gillman, Kris Thielemans, Evgueni Ovtchinnikov
# Licence: Apache-2.0
# Copyright (C) 2021 Commonwealth Scientific and Industrial Research Organisation
# Copyright (C) 2024 University College London
# Copyright (C) 2024 STFC, UK Research and Innovation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import importlib
pet = importlib.import_module('sirf.STIR')
import logging

logger = logging.getLogger("PETRIC")
DATA_PATH = '/home/sirfuser/devel/SyneRBI-Challenge/data'


def the_data_path(*data_type):
Expand All @@ -30,13 +20,7 @@ def the_data_path(*data_type):
data_type: either 'PET', 'MR' or 'Synergistic', or use multiple arguments for
subdirectories like the_data_path('PET', 'mMR', 'NEMA_IQ').
'''
try:
from .data_path import data_path
except ImportError:
raise RuntimeError(
"Path to data not found.")

return os.path.join(data_path, *data_type)
return os.path.join(DATA_PATH, *data_type)


def fix_siemens_norm_EOL(in_filename, out_filename):
Expand Down Expand Up @@ -132,7 +116,7 @@ def prepare_challenge_Siemens_data(data_path, challenge_data_path, intermediate_
logger.info('data shape: %s' % repr(prompts.shape))
logger.info('prompts norm: %f' % prompts.norm())
logger.info('randoms norm: %f' % randoms.norm())

logger.info(f'writing prompts to {f_prompts} and randoms to {f_randoms}')
prompts.write(f_prompts)
randoms.write(f_randoms)
Expand Down Expand Up @@ -176,8 +160,7 @@ def prepare_challenge_Siemens_data(data_path, challenge_data_path, intermediate_
asm_mf.normalise(background)
logger.info('norm of the additive term: %f' % background.norm())
logger.info(f'writing additive term to {f_additive}')

background.write(f_additive)

return

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os
import sys
this_directory = os.path.dirname(__file__)
repo_directory = os.path.dirname(os.path.dirname(this_directory))
sys.path.append(os.path.join(repo_directory, 'lib'))
sys.path.append(this_directory)
repo_directory = os.path.dirname(this_directory)
challenge_data_path = os.path.join(repo_directory, 'data')

import importlib
pet = importlib.import_module('sirf.STIR')
Expand All @@ -14,6 +15,7 @@
import logging
import argparse


if __name__ == '__main__':
parser = argparse.ArgumentParser(description='SyneRBI Challenge 2024 data preparation script.')

Expand All @@ -30,18 +32,17 @@

start = args.start
end = args.end

if args.raw_data_path is None:
data_path = the_data_path('PET', 'mMR', 'NEMA_IQ')
else:
data_path = args.raw_data_path

data_path = os.path.abspath(data_path)
logging.debug(f"Raw data path: {data_path}")


sirf_data_path = os.path.join(examples_data_path('PET'), 'mMR')
challenge_data_path = os.path.join(repo_directory, 'data')
intermediate_data_path = os.path.join(challenge_data_path, 'intermediate')
os.makedirs(challenge_data_path, exist_ok=True)
os.chdir(challenge_data_path)
Expand All @@ -54,4 +55,3 @@
'60min_UCL.l.hdr', 'MUMAP_UCL.v', 'MUMAP_UCL.hv', 'UCL.n', 'norm.n.hdr', f_template + '.hs',
'prompts', 'multfactors', 'additive', 'randoms',
'attenuation_factor', 'attenuation_correction_factor', 'scatter', start, end)

1 change: 0 additions & 1 deletion lib/data_utilities/data_path.py

This file was deleted.

0 comments on commit bf940ca

Please sign in to comment.