Skip to content

Commit d80628f

Browse files
committed
First commit
1 parent 4f9f3ca commit d80628f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+6275
-9
lines changed

.gitignore

+11-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ env/
1111
build/
1212
develop-eggs/
1313
dist/
14-
downloads/
1514
eggs/
1615
lib/
1716
lib64/
@@ -23,8 +22,8 @@ var/
2322
*.egg
2423

2524
# PyInstaller
26-
# Usually these files are written by a python script from a template
27-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
25+
# Usually these files are written by a python script from a template
26+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
2827
*.manifest
2928
*.spec
3029

@@ -52,3 +51,12 @@ docs/_build/
5251

5352
# PyBuilder
5453
target/
54+
55+
#Temporal files
56+
*~
57+
58+
#PyCharm Project
59+
.idea/
60+
61+
#reference code
62+
devdoc/

CHANGES.rst

Whitespace-only changes.

Makefile

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
.PHONY: help clean clean-pyc clean-build list test test-all coverage docs release sdist install develop install_deps
2+
3+
help:
4+
@echo "clean-build - remove build artifacts"
5+
@echo "clean-pyc - remove Python file artifacts"
6+
@echo "lint - check style with flake8"
7+
@echo "test - run tests quickly with the default Python"
8+
@echo "testall - run tests on every Python version with tox"
9+
@echo "coverage - check code coverage quickly with the default Python"
10+
@echo "docs - generate Sphinx HTML documentation, including API docs"
11+
@echo "release - package and upload a release"
12+
@echo "sdist - package"
13+
@echo "install - install"
14+
@echo "develop - install in development mode"
15+
16+
install: install_deps
17+
python setup.py install
18+
19+
develop: install_deps
20+
python setup.py develop
21+
22+
install_deps:
23+
./install_deps.py requirements.txt
24+
25+
clean: clean-build clean-pyc
26+
27+
clean-build:
28+
rm -fr build/
29+
rm -fr dist/
30+
rm -fr *.egg-info
31+
32+
clean-pyc:
33+
find . -name '*.pyc' -exec rm -f {} +
34+
find . -name '*.pyo' -exec rm -f {} +
35+
find . -name '*~' -exec rm -f {} +
36+
37+
lint:
38+
flake8 boyle test
39+
40+
test:
41+
py.test
42+
43+
test-all:
44+
tox
45+
46+
coverage:
47+
coverage run --source boyle setup.py test
48+
coverage report -m
49+
coverage html
50+
open htmlcov/index.html
51+
52+
docs:
53+
rm -f docs/boyle.rst
54+
rm -f docs/modules.rst
55+
sphinx-apidoc -o docs/ boyle
56+
$(MAKE) -C docs clean
57+
$(MAKE) -C docs html
58+
open docs/_build/html/index.html
59+
60+
release: clean
61+
python setup.py sdist upload
62+
python setup.py bdist_wheel upload
63+
64+
sdist: clean
65+
python setup.py sdist
66+
python setup.py bdist_wheel upload
67+
ls -l dist

README.md

-6
This file was deleted.

README.rst

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
.. -*- mode: rst -*-
2+
3+
boyle
4+
=====
5+
6+
Medical Image Conversion and Input/Output Tools
7+
8+
Named after Robert Boyle (1627-1691), known as the first modern chemist, although he believed in the transmutation of metals to be a possibility following the alchemical tradition.
9+
10+
.. image:: https://secure.travis-ci.org/alexsavio/boyle.png?branch=master
11+
:target: https://travis-ci.org/alexsavio/boyle
12+
.. image:: https://coveralls.io/repos/alexsavio/boyle/badge.png
13+
:target: https://coveralls.io/r/alexsavio/boyle
14+
15+
16+
Dependencies
17+
============
18+
19+
Please see the requirements.txt file.
20+
21+
Install
22+
=======
23+
24+
Before installing it, you need all the requirements installed.
25+
These are listed in the requirements.txt files.
26+
The best way to install them is running the following command:
27+
28+
for r in \`cat boyle/requirements.txt\`; do pip install $r; done
29+
30+
This package uses distutils, which is the default way of installing
31+
python modules. To install in your home directory, use::
32+
33+
python setup.py install --user
34+
35+
To install for all users on Unix/Linux::
36+
37+
python setup.py build
38+
sudo python setup.py install
39+
40+
41+
Development
42+
===========
43+
44+
Code
45+
----
46+
47+
Github
48+
~~~~~~
49+
50+
You can check the latest sources with the command::
51+
52+
git clone https://www.github.com/Neurita/boyle.git
53+
54+
or if you have write privileges::
55+
56+
git clone [email protected]:Neurita/boyle.git
57+
58+
If you are going to create patches for this project, create a branch for it
59+
from the master branch.
60+
61+
The stable releases are tagged in the repository.
62+
63+
64+
Testing
65+
-------
66+
67+
TODO

boyle/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
from .logger import setup_logging
3+
4+
setup_logging()

boyle/commands.py

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# coding=utf-8
2+
#------------------------------------------------------------------------------
3+
4+
#Author: Alexandre Manhaes Savio
5+
#Grupo de Inteligencia Computational <www.ehu.es/ccwintco>
6+
#Universidad del Pais Vasco UPV/EHU
7+
8+
#License: 3-Clause BSD
9+
10+
#2013, Alexandre Manhaes Savio
11+
#Use this at your own risk!
12+
#------------------------------------------------------------------------------
13+
14+
import subprocess
15+
import logging
16+
17+
log = logging.getLogger(__name__)
18+
19+
20+
def check_call(cmd_args):
21+
"""
22+
Calls the command
23+
24+
Parameters
25+
----------
26+
cmd_args: list of str
27+
Command name to call and its arguments in a list.
28+
29+
Returns
30+
-------
31+
Command output
32+
"""
33+
p = subprocess.Popen(cmd_args, stdout=subprocess.PIPE)
34+
(output, err) = p.communicate()
35+
return output
36+
37+
38+
def condor_call(cmd, shell=True):
39+
"""
40+
Tries to submit cmd to HTCondor, if it does not succeed, it will
41+
be called with subprocess.call.
42+
43+
Parameters
44+
----------
45+
cmd: string
46+
Command to be submitted
47+
48+
Returns
49+
-------
50+
"""
51+
log.info(cmd)
52+
ret = condor_submit(cmd)
53+
if ret != 0:
54+
subprocess.call(cmd, shell=shell)
55+
56+
57+
def condor_submit(cmd):
58+
"""
59+
Submits cmd to HTCondor queue
60+
61+
Parameters
62+
----------
63+
cmd: string
64+
Command to be submitted
65+
66+
Returns
67+
-------
68+
int
69+
returncode value from calling the submission command.
70+
"""
71+
try:
72+
is_running = subprocess.call('condor_status', shell=True) == 0
73+
except Exception as exc:
74+
log.exception('Could not find a running instance of HTCondor.')
75+
raise
76+
77+
sub_cmd = 'condor_qsub -shell n -b y -r y -N ' \
78+
+ cmd.split()[0] + ' -m n'
79+
80+
log.info('Calling: ' + sub_cmd)
81+
82+
return subprocess.call(sub_cmd + ' ' + cmd, shell=True)
83+
84+
85+
# if [ $scriptmode -ne 1 ] ; then
86+
# sge_command="$qsub_cmd -V -cwd -shell n -b y -r y $queueCmd $pe_options -M $mailto -N $JobName -m $MailOpts $LogOpts $sge_arch $sge_hol
87+
# d"
88+
# else
89+
# sge_command="$qsub_cmd $LogOpts $sge_arch $sge_hold"
90+
# fi
91+
# if [ $verbose -eq 1 ] ; then
92+
# echo sge_command: $sge_command >&2
93+
# echo executing: $@ >&2
94+
# fi
95+
# exec $sge_command $@ | awk '{print $3}'
96+

boyle/config.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
import os
3+
import logging
4+
from collections import OrderedDict
5+
6+
#Known two-part file extensions
7+
ALLOWED_EXTS = {'.gz': {'.nii'}}
8+
9+
LOG_LEVEL = logging.INFO
10+
11+
#Acceptable extensions for DICOM files
12+
DICOM_FILE_EXTENSIONS = ['.IMA', '.DICOM', '.DCM']
13+
DICOM_FILE_EXTENSIONS.extend([x.lower() for x in DICOM_FILE_EXTENSIONS])
14+
OUTPUT_DICOM_EXTENSION = '.dcm'
15+
16+
#MACUTO-DATA PATH
17+
TESTDATA_PATH = os.path.join(os.path.dirname(__file__), '..', 'macuto-data')
18+
19+
#DICOM field weights for dicom.comparison
20+
DICOM_FIELD_WEIGHTS = OrderedDict([('PatientID', 1),
21+
('PatientName', 1),
22+
('PatientAddress', 0.5),
23+
('PatientSex', 0.2),
24+
('AcquisitionDate', 0.2),
25+
('PatientBirthDate', 0.3)])

0 commit comments

Comments
 (0)