@@ -83,7 +83,7 @@ def to_string(self, banner=None):
83
83
return string % self
84
84
85
85
@classmethod
86
- def from_binary (cls , byte_stream , index = None ):
86
+ def from_binary (cls , byte_stream , index = 0 ):
87
87
"""Read the struct from a matlab binary file."""
88
88
mdict = _read_mat (byte_stream )
89
89
return cls .from_matlab_dict (mdict , index = index )
@@ -96,14 +96,12 @@ def from_fileobj(cls, fileobj, check=True):
96
96
return cls .from_string (fileobj .read ())
97
97
98
98
@classmethod
99
- def from_matlab_dict (cls , mdict , index = None ):
99
+ def from_matlab_dict (cls , mdict , index = 0 ):
100
100
"""Read the struct from a matlab dictionary."""
101
101
tf = cls ()
102
102
sa = tf .structarr
103
- if index is not None :
104
- raise NotImplementedError
105
103
106
- sa ['index' ] = 0
104
+ sa ['index' ] = index
107
105
parameters = np .eye (4 , dtype = 'f4' )
108
106
parameters [:3 , :3 ] = mdict ['AffineTransform_float_3_3' ][:- 3 ].reshape ((3 , 3 ))
109
107
parameters [:3 , 3 ] = mdict ['AffineTransform_float_3_3' ][- 3 :].flatten ()
@@ -184,7 +182,7 @@ def __getitem__(self, idx):
184
182
def to_filename (self , filename ):
185
183
"""Store this transform to a file with the appropriate format."""
186
184
if str (filename ).endswith ('.mat' ):
187
- raise NotImplementedError
185
+ raise TransformFileError ( 'Please use the ITK \' s new .h5 format.' )
188
186
189
187
with open (str (filename ), 'w' ) as f :
190
188
f .write (self .to_string ())
0 commit comments