NIPY logo

Site Navigation

NIPY Community

Github repo

Table Of Contents

Previous topic

algorithms.diagnostics.screens

Next topic

algorithms.diagnostics.tsdiffplot

This Page

algorithms.diagnostics.timediff

Module: algorithms.diagnostics.timediff

Time series diagnostics

These started life as tsdiffana.m - see http://imaging.mrc-cbu.cam.ac.uk/imaging/DataDiagnostics

Oliver Josephs (FIL) gave me the idea of time-point to time-point subtraction as a diagnostic for motion and other sudden image changes.

nipy.algorithms.diagnostics.timediff.time_slice_diffs(arr, time_axis=-1, slice_axis=-2)

Time-point to time-point differences over volumes and slices

We think of the passed array as an image. The image has a “time” dimension given by time_axis and a “slice” dimension, given by slice_axis, and one or other dimensions. In the case of imaging there will usually be two more dimensions (the dimensions defining the size of an image slice). A single slice in the time dimension we call a “volume”. A single entry in arr is a “voxel”. For example, if time_axis == 0, then v = arr[0] would be the first volume in the series. The volume v above has v.size voxels. If, in addition, slice_axis == 1, then for the volume v (above) s = v[0] would be a “slice”, with s.size voxels. These are obviously terms from neuroimaging.

Parameters :

arr : array_like

Array over which to calculate time and slice differences. We’ll call this array an ‘image’ in this doc.

time_axis : int

axis of arr that varies over time.

slice_axis : int

axis of arr that varies over image slice.

Returns :

results : dict

Here T is the number of time points (arr.shape[time_axis]) and S is the number of slices (arr.shape[slice_axis]), v is the shape of a volume, and d2[t] is the volume of squared differences between voxels at time point t and time point t+1

results has keys:

  • ‘volume_mean_diff2’ : (T-1,) array

    array containing the mean (over voxels in volume) of the squared difference from one time point to the next

  • ‘slice_mean_diff2’ : (T-1, S) array

    giving the mean (over voxels in slice) of the difference from one time point to the next, one value per slice, per timepoint

  • ‘volume_means’ : (T,) array

    mean over voxels for each volume ``vol[t] for t in 0:T

  • ‘slice_diff2_max_vol’ : v[:] array

    volume, of same shape as input volumes, where each slice is is the slice from d2[t] for t in 0:T-1, that has the largest variance across t. Thus each slice in the volume may well result from a different difference time point.

  • ‘diff2_mean_vol`` : v[:] array

    volume with the mean of d2[t] across t for t in 0:T-1.