-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopyMetaData.py
More file actions
29 lines (18 loc) · 755 Bytes
/
Copy pathCopyMetaData.py
File metadata and controls
29 lines (18 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import numpy as np
import sys
import nrrd
if (len(sys.argv) < 3):
print 'Error: missing arguments!'
print 'e.g. python CopyMetaData.py CorrectImage.nrrd DataToBeCorrected.nrrd'
else:
print 'Copying Meta data from ', str(sys.argv[1]), ' onto that of ', str(sys.argv[2]), '...'
readdata, op1 = nrrd.read(str(sys.argv[2]))
im1 = readdata
readdata, op2 = nrrd.read(str(sys.argv[1]))
im2 = readdata
if (im1.size <> im2.size):
print '\n\nError: Images must be the same size!!'
else:
print 'Changing the meta data for %s to match that of %s' %(str(sys.argv[2]),str(sys.argv[1]))
nrrd.write(str(sys.argv[2]), im1, options=op2)
print 'Done.'