@@ -254,7 +254,14 @@ def convolve_and_rescale(array, func, rescale="rescale", pad=False):
254254
255255
256256def export_metric (
257- metric , sample_rate , tr , fileprefix , ext = ".1D" , is_convolved = True , has_lags = False
257+ metric ,
258+ sample_rate ,
259+ tr ,
260+ fileprefix ,
261+ ntp = None ,
262+ ext = ".1D" ,
263+ is_convolved = True ,
264+ has_lags = False ,
258265):
259266 """
260267 Export the metric content, both in original sampling rate and resampled at the TR.
@@ -269,6 +276,8 @@ def export_metric(
269276 TR of functional data. Output will be also resampled to this value
270277 fileprefix : str
271278 Filename prefix, including path where files should be stored
279+ ntp : int or None, optional
280+ Number of timepoints to consider, if None, all will be automatically considered
272281 ext : str, optional
273282 Extension of file, default "1D"
274283 is_convolved : bool, optional.
@@ -285,6 +294,13 @@ def export_metric(
285294 f = interp1d (orig_t , metric , fill_value = "extrapolate" , axis = 0 )
286295
287296 resampled_metric = f (interp_t )
297+ if ntp is not None :
298+ if resampled_metric .shape [- 1 ] > ntp :
299+ resampled_metric = resampled_metric [:ntp ]
300+ elif resampled_metric .shape [- 1 ] < ntp :
301+ resampled_metric = np .pad (
302+ resampled_metric .T , (0 , ntp - resampled_metric .shape [- 1 ]), mode = "edge"
303+ ).T
288304
289305 # Export metrics
290306 if metric .ndim == 1 :
0 commit comments