I was interested to know why when an across images method is applied, such as image.mean(), image.max(), or image.std(), that the final dimensions are left as (1, dim1, dim2), rather than squeezing out the first singleton dimension? I ran into a couple bumps from this functionality.
In the registration tutorials, to create a reference, .toarray() is always used. I'm guessing because it is assumed the tutorials are being done in local mode. toarray() squeezes out these extra dimensions.
When generating my own reference as a mean, image.mean() provides this additional dimension so that in and of itself does not work as a reference because the dimensions don't match. I attempted to do a image.squeeze() to fix this, but it didn't work, as it only works from [1:] in lines 240-245 of thunder/images.py:
Is there a reason that thunder is pushing/forcing a toarray() call to successfully squeeze out these dimensions? Would it be appropriate to have these functions that apply a function across all images simply return the array with a squeeze() call built in? Otherwise, could we alter images.squeeze() to remove that first singleton dimension?
I'd be happy to submit a pull request to try and implement this, but I wanted to understand the rationale behind why toarray() is currently the only way to squeeze out that dimension and images.squeeze() doesn't work that way, or even the condensing functions themselves (images.mean(), images.std(), etc...). That way it can be implemented in the most beneficial manner. I think simply altering images.squeeze() would be the simplest to change from a pull-request point of view.
I was interested to know why when an across images method is applied, such as
image.mean()
,image.max()
, orimage.std()
, that the final dimensions are left as (1, dim1, dim2), rather than squeezing out the first singleton dimension? I ran into a couple bumps from this functionality.In the registration tutorials, to create a reference,
.toarray()
is always used. I'm guessing because it is assumed the tutorials are being done in local mode.toarray()
squeezes out these extra dimensions.When generating my own reference as a mean,
image.mean()
provides this additional dimension so that in and of itself does not work as a reference because the dimensions don't match. I attempted to do aimage.squeeze()
to fix this, but it didn't work, as it only works from [1:] in lines 240-245 of thunder/images.py:def squeeze(self): """ Remove single-dimensional axes from images. """ axis = tuple(range(1, len(self.shape) - 1)) if prod(self.shape[1:]) == 1 else None return self.map(lambda x: x.squeeze(axis=axis))
Is there a reason that thunder is pushing/forcing a
toarray()
call to successfully squeeze out these dimensions? Would it be appropriate to have these functions that apply a function across all images simply return the array with asqueeze()
call built in? Otherwise, could we alter images.squeeze() to remove that first singleton dimension?I'd be happy to submit a pull request to try and implement this, but I wanted to understand the rationale behind why
toarray()
is currently the only way to squeeze out that dimension andimages.squeeze()
doesn't work that way, or even the condensing functions themselves (images.mean()
,images.std()
, etc...). That way it can be implemented in the most beneficial manner. I think simply alteringimages.squeeze()
would be the simplest to change from a pull-request point of view.