File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
Wrapping/Generators/Python Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -387,6 +387,12 @@ def custom_callback(name, progress):
387
387
assert False
388
388
except ValueError :
389
389
pass
390
+
391
+ empty_array = np .array ([], dtype = np .uint8 )
392
+ empty_array .shape = (0 ,0 ,0 )
393
+ empty_image = itk .image_from_array (empty_array )
394
+ empty_da = itk .xarray_from_image (empty_image )
395
+ empty_image_round = itk .image_from_xarray (empty_da )
390
396
except ImportError :
391
397
print ('xarray not imported. Skipping xarray conversion tests' )
392
398
pass
Original file line number Diff line number Diff line change @@ -444,8 +444,10 @@ def image_from_xarray(data_array):
444
444
origin = [0.0 ]* spatial_dimension
445
445
spacing = [1.0 ]* spatial_dimension
446
446
for index , dim in enumerate (spatial_dims ):
447
- origin [index ] = float (data_array .coords [dim ][0 ])
448
- spacing [index ] = float (data_array .coords [dim ][1 ]) - float (data_array .coords [dim ][0 ])
447
+ coords = data_array .coords [dim ]
448
+ if coords .shape [0 ] > 1 :
449
+ origin [index ] = float (coords [0 ])
450
+ spacing [index ] = float (coords [1 ]) - float (coords [0 ])
449
451
spacing .reverse ()
450
452
itk_image .SetSpacing (spacing )
451
453
origin .reverse ()
You can’t perform that action at this time.
0 commit comments