|
| 1 | +# ========================================================================== |
| 2 | +# |
| 3 | +# Copyright NumFOCUS |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0.txt |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | +# ==========================================================================*/ |
| 18 | + |
| 19 | +# Ensure we can convert all Nifti metadata members to Python |
| 20 | + |
| 21 | +import sys |
| 22 | +import numpy as np |
| 23 | +import pathlib |
| 24 | +from pprint import pprint |
| 25 | + |
| 26 | +import itk |
| 27 | + |
| 28 | +nifti_image_2d_filepath = sys.argv[1] |
| 29 | +image = itk.imread(nifti_image_2d_filepath) |
| 30 | +metadata = dict(image) |
| 31 | +print('2D image') |
| 32 | +pprint(metadata) |
| 33 | + |
| 34 | +nifti_image_3d_filepath = sys.argv[2] |
| 35 | +image = itk.imread(nifti_image_3d_filepath, itk.F) |
| 36 | +metadata = dict(image) |
| 37 | +print('3D image') |
| 38 | +pprint(metadata) |
| 39 | + |
| 40 | +nifti_displacement_2D_filepath = sys.argv[3] |
| 41 | +field = itk.imread(nifti_displacement_2D_filepath, itk.F) |
| 42 | +metadata = dict(field) |
| 43 | +print('2D displacement field') |
| 44 | +pprint(metadata) |
| 45 | + |
| 46 | +nifti_displacement_3D_filepath = sys.argv[4] |
| 47 | +field = itk.imread(nifti_displacement_3D_filepath, itk.F) |
| 48 | +metadata = dict(field) |
| 49 | +print('3D displacement field') |
| 50 | +pprint(metadata) |
0 commit comments