From eb40d0825deff4f9cccc8875fecf08093d198be6 Mon Sep 17 00:00:00 2001 From: mtnhuck Date: Fri, 12 Jan 2018 17:09:13 -0500 Subject: [PATCH 01/14] Updating data definitions for Siemens BIDS2NDA conversion scanner_software_versions_pd get from SoftwareVersions edited at line 165: dict_append(image03_dict, 'scanner_software_versions_pd', metadata.get("HardcopyDeviceSoftwareVersion", "")) to dict_append(image03_dict, 'scanner_software_versions_pd', metadata.get("SoftwareVersions", "")) image_slice_thickness SliceThickness Inserted at line 170 dict_append(image03_dict, 'image_slice_thickness', metadata.get("SliceThickness", "")) --- bids2nda/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bids2nda/main.py b/bids2nda/main.py index c83b787..c565581 100644 --- a/bids2nda/main.py +++ b/bids2nda/main.py @@ -162,11 +162,12 @@ def run(args): dict_append(image03_dict, 'image_modality', "MRI") dict_append(image03_dict, 'scanner_manufacturer_pd', metadata.get("Manufacturer", "")) dict_append(image03_dict, 'scanner_type_pd', metadata.get("ManufacturersModelName", "")) - dict_append(image03_dict, 'scanner_software_versions_pd', metadata.get("HardcopyDeviceSoftwareVersion", "")) + dict_append(image03_dict, 'scanner_software_versions_pd', metadata.get("SoftwareVersions", "")) dict_append(image03_dict, 'magnetic_field_strength', metadata.get("MagneticFieldStrength", "")) dict_append(image03_dict, 'mri_echo_time_pd', metadata.get("EchoTime", "")) dict_append(image03_dict, 'flip_angle', metadata.get("FlipAngle", "")) dict_append(image03_dict, 'receive_coil', metadata.get("ReceiveCoilName", "")) + dict_append(image03_dict, 'image_slice_thickness', metadata.get("SliceThickness", "")) dict_append(image03_dict, 'transformation_performed', 'Yes') dict_append(image03_dict, 'transformation_type', 'BIDS2NDA') From 7b5737e70f37fc90ba9284ceadbd73995bcc880a Mon Sep 17 00:00:00 2001 From: mtnhuck Date: Fri, 12 Jan 2018 17:34:24 -0500 Subject: [PATCH 02/14] Data dictionary for image_orientation Edited to include image_orientation image_orientation: modified from https://stackoverflow.com/questions/34782409/understanding-dicom-image-a ttributes-to-get-axial-coronal-sagittal-cuts and https://github.com/rordenlab/dcm2niix/issues/153#event-1421631442 photomet_interpret: from DICOM/JSON field PhotometricInterpretation --- bids2nda/main.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bids2nda/main.py b/bids2nda/main.py index c565581..333dec7 100644 --- a/bids2nda/main.py +++ b/bids2nda/main.py @@ -167,7 +167,17 @@ def run(args): dict_append(image03_dict, 'mri_echo_time_pd', metadata.get("EchoTime", "")) dict_append(image03_dict, 'flip_angle', metadata.get("FlipAngle", "")) dict_append(image03_dict, 'receive_coil', metadata.get("ReceiveCoilName", "")) - dict_append(image03_dict, 'image_slice_thickness', metadata.get("SliceThickness", "")) + dict_append(image03_dict, 'image_slice_thickness', metadata.get("SliceThickness", "")) + dict_append(image03_dict, 'photomet_interpret', metadata.get("PhotometricInterpretation", "")) + + plane = metadata.get("ImageOrientationPatient") + plane=round(plane) + if plane[0] == 1: + dict_append(image03_dict, 'image_orientation.', "Sagittal") + elif plane[1] == 1: + dict_append(image03_dict, 'image_orientation.', "Coronal") + elif plane[2] == 1: + dict_append(image03_dict, 'image_orientation.', "Axial") dict_append(image03_dict, 'transformation_performed', 'Yes') dict_append(image03_dict, 'transformation_type', 'BIDS2NDA') From 4fa8695aa7010ac7832beccb546ae2fb8667e910 Mon Sep 17 00:00:00 2001 From: mtnhuck Date: Fri, 12 Jan 2018 17:54:07 -0500 Subject: [PATCH 03/14] Slightly modified readme.md Added a notes section talking about required experiment_id field --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 069e0fb..e9b180d 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Extract NIHM Data Archive compatible metadata from Brain Imaging Data Structure optional arguments: -h, --help show this help message and exit - + ## GUID_MAPPING file format The is the file format produced by the GUID Tool: one line per subject in the format @@ -32,3 +32,7 @@ The is the file format produced by the GUID Tool: one line per subject in the fo ## Example outputs See [/examples](/examples) + +## Notes: +Column experiment_id must be manually filled in for now. +This is based on experiment ID's received from NDA after setting the study up through the NDA website [here](https://ndar.nih.gov/user/dashboard/collections.html). From e19b5edd61f13cc1beab868b6dfd47f427a68c67 Mon Sep 17 00:00:00 2001 From: mtnhuck Date: Sat, 13 Jan 2018 16:34:25 -0500 Subject: [PATCH 04/14] Edits to try to fix image_orientation --- bids2nda/main.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/bids2nda/main.py b/bids2nda/main.py index 333dec7..41d4cd2 100644 --- a/bids2nda/main.py +++ b/bids2nda/main.py @@ -15,6 +15,7 @@ import nibabel as nb import json import pandas as pd +import numpy as np # Gather our code in a main() function @@ -171,13 +172,8 @@ def run(args): dict_append(image03_dict, 'photomet_interpret', metadata.get("PhotometricInterpretation", "")) plane = metadata.get("ImageOrientationPatient") - plane=round(plane) - if plane[0] == 1: - dict_append(image03_dict, 'image_orientation.', "Sagittal") - elif plane[1] == 1: - dict_append(image03_dict, 'image_orientation.', "Coronal") - elif plane[2] == 1: - dict_append(image03_dict, 'image_orientation.', "Axial") + get_orientation = lambda place: ['Axial','Coronal','Sagittal'][np.argmax(plane[:3])] + dict_append(image03_dict, 'image_orientation.',get_orientation(plane)) dict_append(image03_dict, 'transformation_performed', 'Yes') dict_append(image03_dict, 'transformation_type', 'BIDS2NDA') From 882effcb6747528cdc6c93b9afcef4461db49531 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Sat, 13 Jan 2018 22:27:30 -0500 Subject: [PATCH 05/14] BF: better to have TODO than an incorrect value for now --- bids2nda/main.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bids2nda/main.py b/bids2nda/main.py index 41d4cd2..25934e1 100644 --- a/bids2nda/main.py +++ b/bids2nda/main.py @@ -171,9 +171,7 @@ def run(args): dict_append(image03_dict, 'image_slice_thickness', metadata.get("SliceThickness", "")) dict_append(image03_dict, 'photomet_interpret', metadata.get("PhotometricInterpretation", "")) - plane = metadata.get("ImageOrientationPatient") - get_orientation = lambda place: ['Axial','Coronal','Sagittal'][np.argmax(plane[:3])] - dict_append(image03_dict, 'image_orientation.',get_orientation(plane)) + dict_append(image03_dict, 'image_orientation', 'TODO') # see https://github.com/INCF/BIDS2NDA/issues/12 dict_append(image03_dict, 'transformation_performed', 'Yes') dict_append(image03_dict, 'transformation_type', 'BIDS2NDA') From ef32caf4e3efa069ce433e64b74e19460e975f74 Mon Sep 17 00:00:00 2001 From: mtnhuck Date: Sun, 14 Jan 2018 00:04:57 -0500 Subject: [PATCH 06/14] Update references Updated for SliceThickness and PhotometricInterpretation --- bids2nda/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bids2nda/main.py b/bids2nda/main.py index 41d4cd2..3c27d10 100644 --- a/bids2nda/main.py +++ b/bids2nda/main.py @@ -168,8 +168,8 @@ def run(args): dict_append(image03_dict, 'mri_echo_time_pd', metadata.get("EchoTime", "")) dict_append(image03_dict, 'flip_angle', metadata.get("FlipAngle", "")) dict_append(image03_dict, 'receive_coil', metadata.get("ReceiveCoilName", "")) - dict_append(image03_dict, 'image_slice_thickness', metadata.get("SliceThickness", "")) - dict_append(image03_dict, 'photomet_interpret', metadata.get("PhotometricInterpretation", "")) + dict_append(image03_dict, 'image_slice_thickness', metadata.get("global.const.SliceThickness", "")) + dict_append(image03_dict, 'photomet_interpret', metadata.get("global.const.PhotometricInterpretation", "")) plane = metadata.get("ImageOrientationPatient") get_orientation = lambda place: ['Axial','Coronal','Sagittal'][np.argmax(plane[:3])] From 80ee7fff407281a67bbb0daf88821d4a555566fd Mon Sep 17 00:00:00 2001 From: mtnhuck Date: Mon, 15 Jan 2018 10:51:57 -0500 Subject: [PATCH 07/14] Finally got it to pull PhotometricInterpretation but doesn't work for fieldmaps --- bids2nda/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bids2nda/main.py b/bids2nda/main.py index 3c27d10..c37e46b 100644 --- a/bids2nda/main.py +++ b/bids2nda/main.py @@ -168,10 +168,9 @@ def run(args): dict_append(image03_dict, 'mri_echo_time_pd', metadata.get("EchoTime", "")) dict_append(image03_dict, 'flip_angle', metadata.get("FlipAngle", "")) dict_append(image03_dict, 'receive_coil', metadata.get("ReceiveCoilName", "")) - dict_append(image03_dict, 'image_slice_thickness', metadata.get("global.const.SliceThickness", "")) - dict_append(image03_dict, 'photomet_interpret', metadata.get("global.const.PhotometricInterpretation", "")) - plane = metadata.get("ImageOrientationPatient") + + plane = metadata.get("ImageOrientationPatient","") get_orientation = lambda place: ['Axial','Coronal','Sagittal'][np.argmax(plane[:3])] dict_append(image03_dict, 'image_orientation.',get_orientation(plane)) dict_append(image03_dict, 'transformation_performed', 'Yes') @@ -201,6 +200,8 @@ def run(args): dict_append(image03_dict, 'image_resolution1', nii.header.get_zooms()[0]) dict_append(image03_dict, 'image_resolution2', nii.header.get_zooms()[1]) dict_append(image03_dict, 'image_resolution3', nii.header.get_zooms()[2]) + dict_append(image03_dict, 'image_slice_thickness', nii.header.get_zooms()[2]) + dict_append(image03_dict, 'photomet_interpret', metadata.get("global",{}).get("const",{}).get("PhotometricInterpretation"),"")) if len(nii.shape) > 3: image_resolution4 = nii.header.get_zooms()[3] else: From e4eb087c9f35404a88ece846de28a8b79d2706fb Mon Sep 17 00:00:00 2001 From: leej3 Date: Thu, 1 Feb 2018 18:17:14 -0500 Subject: [PATCH 08/14] fix photomet and image_orientation additions --- bids2nda/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bids2nda/main.py b/bids2nda/main.py index c37e46b..d732942 100644 --- a/bids2nda/main.py +++ b/bids2nda/main.py @@ -172,7 +172,7 @@ def run(args): plane = metadata.get("ImageOrientationPatient","") get_orientation = lambda place: ['Axial','Coronal','Sagittal'][np.argmax(plane[:3])] - dict_append(image03_dict, 'image_orientation.',get_orientation(plane)) + dict_append(image03_dict, 'image_orientation',get_orientation(plane)) dict_append(image03_dict, 'transformation_performed', 'Yes') dict_append(image03_dict, 'transformation_type', 'BIDS2NDA') @@ -201,7 +201,7 @@ def run(args): dict_append(image03_dict, 'image_resolution2', nii.header.get_zooms()[1]) dict_append(image03_dict, 'image_resolution3', nii.header.get_zooms()[2]) dict_append(image03_dict, 'image_slice_thickness', nii.header.get_zooms()[2]) - dict_append(image03_dict, 'photomet_interpret', metadata.get("global",{}).get("const",{}).get("PhotometricInterpretation"),"")) + dict_append(image03_dict, 'photomet_interpret', metadata.get("global",{}).get("const",{}).get("PhotometricInterpretation","")) if len(nii.shape) > 3: image_resolution4 = nii.header.get_zooms()[3] else: From 36a26953cc92808f151690cc066586698858498e Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Sat, 13 Jan 2018 22:39:07 -0500 Subject: [PATCH 09/14] BF: acquire SliceThickness and PhotometricInterpretation from global.consts section apparently it is not fully flattened by/after heudiconv --- bids2nda/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bids2nda/main.py b/bids2nda/main.py index 25934e1..802b1ce 100644 --- a/bids2nda/main.py +++ b/bids2nda/main.py @@ -156,6 +156,8 @@ def run(args): else: description = suffix dict_append(image03_dict, 'experiment_id', '') + # Shortcut for the global.const section -- apparently might not be flattened fully + metadata_const = metadata.get('global', {}).get('const', {}) dict_append(image03_dict, 'image_description', description) dict_append(image03_dict, 'scan_type', suffix_to_scan_type[suffix]) dict_append(image03_dict, 'scan_object', "Live") @@ -168,9 +170,8 @@ def run(args): dict_append(image03_dict, 'mri_echo_time_pd', metadata.get("EchoTime", "")) dict_append(image03_dict, 'flip_angle', metadata.get("FlipAngle", "")) dict_append(image03_dict, 'receive_coil', metadata.get("ReceiveCoilName", "")) - dict_append(image03_dict, 'image_slice_thickness', metadata.get("SliceThickness", "")) - dict_append(image03_dict, 'photomet_interpret', metadata.get("PhotometricInterpretation", "")) - + dict_append(image03_dict, 'image_slice_thickness', metadata_const.get("SliceThickness", "")) + dict_append(image03_dict, 'photomet_interpret', metadata_const.get('PhotometricInterpretation', '')) dict_append(image03_dict, 'image_orientation', 'TODO') # see https://github.com/INCF/BIDS2NDA/issues/12 dict_append(image03_dict, 'transformation_performed', 'Yes') dict_append(image03_dict, 'transformation_type', 'BIDS2NDA') From 77e9bcf05ef2a361b4c4239079ef829be0509ff4 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Sat, 13 Jan 2018 22:23:30 -0500 Subject: [PATCH 10/14] ENH: figure out slice orientation from "ImageOrientationPatientDICOM" (not correct!) --- bids2nda/main.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/bids2nda/main.py b/bids2nda/main.py index 802b1ce..d5458d2 100644 --- a/bids2nda/main.py +++ b/bids2nda/main.py @@ -75,6 +75,63 @@ def dict_append(d, key, value): d[key] = [value, ] +def cosine_to_orientation(img_ornt_pat): + """Deduce slicing from cosines + + From http://nipy.org/nibabel/dicom/dicom_orientation.html#dicom-voxel-to + -patient-coordinate-system-mapping + + From Section C.7.6.1.1.1 we see that the "positive row axis" is left to + right, and is the direction of the rows, given by the direction of last + pixel in the first row from the first pixel in that row. Similarly the + "positive column axis" is top to bottom and is the direction of the columns, + given by the direction of the last pixel in the first column from the first + pixel in that column. + + Let's rephrase: the first three values of "Image Orientation Patient" are + the direction cosine for the "positive row axis". That is, they express the + direction change in (x, y, z), in the DICOM patient coordinate system + (DPCS), as you move along the row. That is, as you move from one column to + the next. That is, as the column array index changes. Similarly, the second + triplet of values of "Image Orientation Patient" (img_ornt_pat[3:] in + Python), are the direction cosine for the "positive column axis", and + express the direction you move, in the DPCS, as you move from row to row, + and therefore as the row index changes. + + Parameters + ---------- + img_ornt_pat: list of float + Values of the ImageOrientationPatient field + + Returns + ------- + {'Axial', 'Coronal', 'Sagital'} + """ + # we do not care about the signs + img_ornt_pat = np.abs(img_ornt_pat) + # we need to figure out first leading dimension and the 2nd + d1 = int(np.argmax(img_ornt_pat[:3])) + d2 = int(np.argmax(img_ornt_pat[3:])) + ds = tuple(sorted([d1, d2])) + try: + return { + (0, 1): 'Axial', + (1, 2): 'Sagital', + (0, 2): 'Coronal' + }[ds] + except KeyError: + raise RuntimeError( + "Could not deduce the image orientation of %r with both directions " + "being detected as %r. Give us a use-case to fine tune" + % (img_ornt_pat, ds) + ) + + +def test_cosine_to_orientation(): + assert cosine_to_orientation([0.9, -0.03, -0.1, 0.03, 0.9, 0.1]) == 'Axial' + assert cosine_to_orientation([0, 0.9, 0.1, 0.03, 0.1, -0.9]) == 'Coronal' + + def run(args): guid_mapping = dict([line.split(" - ") for line in open(args.guid_mapping).read().split("\n") if line != '']) From ce999489d64a3ca57277bdcebf0e3557b6e9302d Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 21 Jun 2019 15:19:27 -0400 Subject: [PATCH 11/14] RF: use a solution from SO for figuring out orientation --- bids2nda/main.py | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/bids2nda/main.py b/bids2nda/main.py index d5458d2..433e9bc 100644 --- a/bids2nda/main.py +++ b/bids2nda/main.py @@ -75,7 +75,7 @@ def dict_append(d, key, value): d[key] = [value, ] -def cosine_to_orientation(img_ornt_pat): +def cosine_to_orientation(iop): """Deduce slicing from cosines From http://nipy.org/nibabel/dicom/dicom_orientation.html#dicom-voxel-to @@ -100,36 +100,33 @@ def cosine_to_orientation(img_ornt_pat): Parameters ---------- - img_ornt_pat: list of float + iop: list of float Values of the ImageOrientationPatient field Returns ------- - {'Axial', 'Coronal', 'Sagital'} + {'Axial', 'Coronal', 'Sagittal'} """ - # we do not care about the signs - img_ornt_pat = np.abs(img_ornt_pat) - # we need to figure out first leading dimension and the 2nd - d1 = int(np.argmax(img_ornt_pat[:3])) - d2 = int(np.argmax(img_ornt_pat[3:])) - ds = tuple(sorted([d1, d2])) - try: - return { - (0, 1): 'Axial', - (1, 2): 'Sagital', - (0, 2): 'Coronal' - }[ds] - except KeyError: + # Solution based on https://stackoverflow.com/a/45469577 + iop_round = np.round(iop) + plane = np.cross(iop_round[0:3], iop_round[3:6]) + plane = np.abs(plane) + if plane[0] == 1: + return "Sagittal" + elif plane[1] == 1: + return "Coronal" + elif plane[2] == 1: + return "Axial" + else: raise RuntimeError( - "Could not deduce the image orientation of %r with both directions " - "being detected as %r. Give us a use-case to fine tune" - % (img_ornt_pat, ds) + "Could not deduce the image orientation of %r. 'plane' value is %r" + % (iop, plane) ) def test_cosine_to_orientation(): assert cosine_to_orientation([0.9, -0.03, -0.1, 0.03, 0.9, 0.1]) == 'Axial' - assert cosine_to_orientation([0, 0.9, 0.1, 0.03, 0.1, -0.9]) == 'Coronal' + assert cosine_to_orientation([0, 0.9, 0.1, 0.03, 0.1, -0.9]) == 'Sagittal' def run(args): @@ -229,7 +226,7 @@ def run(args): dict_append(image03_dict, 'receive_coil', metadata.get("ReceiveCoilName", "")) dict_append(image03_dict, 'image_slice_thickness', metadata_const.get("SliceThickness", "")) dict_append(image03_dict, 'photomet_interpret', metadata_const.get('PhotometricInterpretation', '')) - dict_append(image03_dict, 'image_orientation', 'TODO') # see https://github.com/INCF/BIDS2NDA/issues/12 + dict_append(image03_dict, 'image_orientation', cosine_to_orientation(metadata.get("ImageOrientationPatient"))) dict_append(image03_dict, 'transformation_performed', 'Yes') dict_append(image03_dict, 'transformation_type', 'BIDS2NDA') From e517ccc895f624c04138d61e1841ca2f57405637 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 21 Jun 2019 15:29:16 -0400 Subject: [PATCH 12/14] ENH: prefer/use ImageOrientationPatientDICOM filled out by recent dcm2niix if available --- bids2nda/main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bids2nda/main.py b/bids2nda/main.py index 433e9bc..139536b 100644 --- a/bids2nda/main.py +++ b/bids2nda/main.py @@ -226,7 +226,14 @@ def run(args): dict_append(image03_dict, 'receive_coil', metadata.get("ReceiveCoilName", "")) dict_append(image03_dict, 'image_slice_thickness', metadata_const.get("SliceThickness", "")) dict_append(image03_dict, 'photomet_interpret', metadata_const.get('PhotometricInterpretation', '')) - dict_append(image03_dict, 'image_orientation', cosine_to_orientation(metadata.get("ImageOrientationPatient"))) + # ImageOrientationPatientDICOM is populated by recent dcm2niix, + # and ImageOrientationPatient might be provided by exhastive metadata + # record done by heudiconv + iop = metadata.get( + 'ImageOrientationPatientDICOM', + metadata_const.get("ImageOrientationPatient", None) + ) + dict_append(image03_dict, 'image_orientation', cosine_to_orientation(iop) if iop else '') dict_append(image03_dict, 'transformation_performed', 'Yes') dict_append(image03_dict, 'transformation_type', 'BIDS2NDA') From dc8d63e9d1a14f76ada9bc2ebce91c653c3ba6eb Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Sun, 23 Jun 2019 21:59:52 -0400 Subject: [PATCH 13/14] RF: move test under tests/test_helpers.py --- bids2nda/main.py | 5 ----- bids2nda/tests/__init__.py | 0 bids2nda/tests/test_helpers.py | 8 ++++++++ setup.py | 4 +++- 4 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 bids2nda/tests/__init__.py create mode 100644 bids2nda/tests/test_helpers.py diff --git a/bids2nda/main.py b/bids2nda/main.py index 168f179..8ebda3f 100644 --- a/bids2nda/main.py +++ b/bids2nda/main.py @@ -124,11 +124,6 @@ def cosine_to_orientation(iop): ) -def test_cosine_to_orientation(): - assert cosine_to_orientation([0.9, -0.03, -0.1, 0.03, 0.9, 0.1]) == 'Axial' - assert cosine_to_orientation([0, 0.9, 0.1, 0.03, 0.1, -0.9]) == 'Sagittal' - - def run(args): guid_mapping = dict([line.split(" - ") for line in open(args.guid_mapping).read().split("\n") if line != '']) diff --git a/bids2nda/tests/__init__.py b/bids2nda/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bids2nda/tests/test_helpers.py b/bids2nda/tests/test_helpers.py new file mode 100644 index 0000000..78f9bda --- /dev/null +++ b/bids2nda/tests/test_helpers.py @@ -0,0 +1,8 @@ +from ..main import cosine_to_orientation + + +def test_cosine_to_orientation(): + assert cosine_to_orientation([0.9, -0.03, -0.1, 0.03, 0.9, 0.1]) == 'Axial' + assert cosine_to_orientation([0, 0.9, 0.1, 0.03, 0.1, -0.9]) == 'Sagittal' + + diff --git a/setup.py b/setup.py index 0035eb1..345871e 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,9 @@ # You can just specify the packages manually here if your project is # simple. Or you can use find_packages. - packages=["bids2nda"], + packages=["bids2nda", + "bids2nda.tests", + ], # List run-time dependencies here. These will be installed by pip when your # project is installed. From 735eab0d0944ae9991fa10a4cdf9148f31d82c0f Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Sun, 23 Jun 2019 22:16:58 -0400 Subject: [PATCH 14/14] ENH: rudimentary .travis.yml to run the mighty single unittest --- .travis.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ff021c1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +language: python + +cache: + directories: + - $HOME/.cache/pip + +python: + - 2.7 + - 3.5 + - 3.6 + - 3.7 + +install: + - travis_retry pip install -e . + - travis_retry pip install pytest pytest-cov coverage + +script: + - python -m pytest --cov=bids2nda -s -v bids2nda + +after_success: + - travis_retry pip install codecov + - codecov \ No newline at end of file