def get_timepoint( data, tp=0 ):
    """Returns the timepoint (3D data volume, lowest is 0) from 4D input.
    
    You can save memory by using [1]:
    nifti.dataobj[..., tp]
    instead: see get_nifti_timepoint()
    
    Works with loop_and_save().
    Call directly, or with niftify().
    
    Ref:
    [1]: http://nipy.org/nibabel/images_and_memory.html
    """
    # Replicating seg_maths -tp

    tp = int(tp)
    
    if len(data.shape) < 4:
        print("Data has fewer than 4 dimensions. Doing nothing...")
        output = data
    else:
        if data.shape[3] < tp:
            print("Data has fewer than {0} timepoints in its 4th dimension.".format(tp))
            output = data
        else:
            output = data[:,:,:,tp]
    return output
        
    # elif len(data.shape) > 4:
        # print("Data has more than 4 dimensions! Assuming the 4th is time ...")
    # End get_timepoint() definition