Exemplo n.º 1
0
def concat(input, axis, fname_output, pixdim):
    """Concatenate NIfTIs along the specified dimension.

    input: Input paths of the files to concatenate. Separate the files by a space.
    """
    # Create nii list
    list_nii = []
    for fname_file in input:
        nii_input = nib.load(fname_file)
        list_nii.append(nii_input)

    # Call concat API
    dim_list = AXES
    index = dim_list.index(axis)
    nii_out = concat_data(list_nii, index, pixdim)

    # Save image
    nib.save(nii_out, fname_output)
 def test_concat_100(self):
     """Use a list of more than 100 files"""
     out = concat_data(self.list_nii * 34, 4)
     assert out.shape == self.list_nii[0].shape + (1, len(self.list_nii) * 34)  # (128, 68, 20, 1, 3)
 def test_concat_pixdim(self):
     pixdim = 0.2
     out = concat_data(self.list_nii, 2, pixdim=pixdim)
     assert np.all(np.isclose(out.header['pixdim'], [-1, 2.1875, 2.1875, 0.2, 1, 0, 0, 0]))
 def test_concat_dim_1(self):
     out = concat_data(self.list_nii, 1)
     assert out.shape == (128, 204, 20)
 def test_concat_dim_4(self):
     out = concat_data(self.list_nii, 4)
     assert out.shape == self.list_nii[0].shape + (1, len(self.list_nii))  # (128, 68, 20, 1, 3)
 def test_concat_dim_def(self):
     out = concat_data(self.list_nii)
     assert out.shape == self.list_nii[0].shape + (len(self.list_nii),)  # (128, 68, 20, 3)