[docs]defget_img_nvols(in_files):""" Calculates the number of volumes in the given nifti image. Parameters ---------- in_files : string (nifti file) Returns ------- out : int number of volumes of input nifti file """fromnibabelimportloadimg=load(in_files)hdr=img.headernvols=Noneiflen(hdr.get_data_shape())>3:nvols=int(hdr.get_data_shape()[3])else:nvols=1returnnvols