Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small utilities related to time-series quality assessment #594

Open
stnava opened this issue Mar 25, 2024 · 1 comment
Open

small utilities related to time-series quality assessment #594

stnava opened this issue Mar 25, 2024 · 1 comment

Comments

@stnava
Copy link
Member

stnava commented Mar 25, 2024

These are notes about some utilities that would be useful.

  • implementation of slice time series ( for assessing motion / registration )
time_series_slice(  img_4d ,   pythonic placeholders for axes to sweep over )

probably just a wrapper for slice_image .... more important would be the display of the slice with some relevant annotation. would be something like :

>>> img=ants.image_read("timeseries.nii.gz")
>>> img
ANTsImage
	 Pixel Type : float (float32)
	 Components : 1
	 Dimensions : (90, 104, 72, 420)
	 Spacing    : (2.0, 2.0, 2.0, 0.72)
	 Origin     : (-90.4777, 30.0725, -58.2543, 0.0)
	 Direction  : [ 0.9998  0.0206 -0.0087  0.      0.0219 -0.9783  0.206   0.      0.0043
  0.2061  0.9785  0.      0.      0.      0.      1.    ]

>>> sv1=ants.slice_image(img,1,50)
>>> sv2=ants.slice_image( sv1,0,40)

then add some information about similarity, distortion and/or motion. see below.

  • a simple time series wrapper for image similarity
time_series_metric(  img_4d, optional img_3d , other_params )

if img_3d is present, assess similarity with next neighbor. otherwise similarity against the reference. returns a numpy array (?)

  • deformation quantification ( a single number ) -- this probably exists but not sure ... would likely want something like norm( grad(U) ) ... would want to assess across a time series.
@ncullen93
Copy link
Member

ncullen93 commented Mar 25, 2024

For the first part - it would be nice to do that with the already supported standard numpy-like indexing (e.g. img[:, 1:50, :, :]) but then an env var or something would be needed to determine whether you want numpy-like slicing to return ants images or arrays. So a general slice function makes sense.

Second part - I can definitely see the utility in adding a ants.metrics sub-module that provides an interface to calculating all types of image similarity metrics.

It would be more pythonic and explicit to have each metric be its own function rather than as a string argument to a general function.

e.g. prefer explicit discovery of metrics:

from ants.metrics import metric1, metric2
result1 = metric1(img1, img2)
result2 = metric2(img1, img2)

instead of:

from ants.metrics import calculate_metric
result1 = calculate_metric(img1, img2, 'metric1')
result2 = calculate_metric(img1, img2, 'metric2')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants