Beispiel #1
0
def read_aps_8bm(image_directory,
                 ind_tomo,
                 ind_flat,
                 image_file_pattern='image_00000.xrm',
                 flat_file_pattern='ref_00000.xrm',
                 proj=None,
                 sino=None):
    """
    Read APS 8-BM tomography data from a stack of xrm files.

    Parameters
    ----------
    image_directory : str
        Path to data folder name without indices and extension.

    ind_tomo : list of int
        Indices of the projection files to read.

    ind_flat : list of int
        Indices of the flat field files to read.

    image_file_pattern: string
        Specify how the projection files are named.

    flat_file_pattern: string
        Specify how the flat reference files are named.

    proj : {sequence, int}, optional
        Specify projections to read. (start, end, step)

    sino : {sequence, int}, optional
        Specify sinograms to read. (start, end, step)

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3D flat field data.

    dictionary
        Image set metadata.
    """
    image_directory = os.path.abspath(image_directory)
    tomo_name = os.path.join(image_directory, 'radios', image_file_pattern)
    flat_name = os.path.join(image_directory, 'flats', flat_file_pattern)
    if proj is not None:
        ind_tomo = ind_tomo[slice(*proj)]
    tomo, metadata = dxreader.read_xrm_stack(tomo_name,
                                             ind=ind_tomo,
                                             slc=(sino, None))

    flat, _ = dxreader.read_xrm_stack(flat_name,
                                      ind=ind_flat,
                                      slc=(sino, None))
    return tomo, flat, metadata
Beispiel #2
0
def read_aps_8bm(image_directory, ind_tomo, ind_flat,
                 image_file_pattern='image_00000.xrm',
                 flat_file_pattern='ref_00000.xrm', proj=None, sino=None):
    """
    Read APS 8-BM tomography data from a stack of xrm files.

    Parameters
    ----------
    image_directory : str
        Path to data folder name without indices and extension.

    ind_tomo : list of int
        Indices of the projection files to read.

    ind_flat : list of int
        Indices of the flat field files to read.

    image_file_pattern: string
        Specify how the projection files are named.

    flat_file_pattern: string
        Specify how the flat reference files are named.

    proj : {sequence, int}, optional
        Specify projections to read. (start, end, step)

    sino : {sequence, int}, optional
        Specify sinograms to read. (start, end, step)

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3D flat field data.

    dictionary
        Image set metadata.
    """
    image_directory = os.path.abspath(image_directory)
    tomo_name = os.path.join(image_directory, 'radios', image_file_pattern)
    flat_name = os.path.join(image_directory, 'flats', flat_file_pattern)
    if proj is not None:
        ind_tomo = ind_tomo[slice(*proj)]
    tomo, metadata = dxreader.read_xrm_stack(
        tomo_name, ind=ind_tomo, slc=(sino, None))

    flat, _ = dxreader.read_xrm_stack(
        flat_name, ind=ind_flat, slc=(sino, None))
    return tomo, flat, metadata
Beispiel #3
0
 def test_read_xrm_stack_gets_x_position_set(self):
     image_data, metadata = reader.read_xrm_stack(
         os.path.join(TEST_DIR, "test_data/test_chip00.xrm"), [0, 1])
     self.assertEqual(metadata["x_positions"], [
         715.3599853515625,
         715.3599853515625,
     ])
Beispiel #4
0
 def test_read_xrm_stack_gets_y_position_set(self):
     image_data, metadata = reader.read_xrm_stack(
         os.path.join(TEST_DIR, "test_data/test_chip00.xrm"), [0, 1])
     self.assertEqual(metadata["y_positions"], [
         -3761.9892578125,
         -3761.9892578125,
     ])
Beispiel #5
0
 def test_read_xrm_stack_gets_theta_set(self):
     image_data, metadata = reader.read_xrm_stack(
         os.path.join(TEST_DIR, "test_data/test_chip00.xrm"), [0, 1])
     self.assertEqual(metadata["thetas"], [
         -0.06000000238418579,
         -0.06000000238418579,
     ])
Beispiel #6
0
 def test_read_xrm_stack_gets_y_position_set(self):
     image_data, metadata = reader.read_xrm_stack(
         os.path.join(TEST_DIR, "test_data/test_chip00.xrm"), [0, 1])
     self.assertEqual(
         metadata["y_positions"],
         [
             -3761.9892578125,
             -3761.9892578125,
         ]
     )
Beispiel #7
0
 def test_read_xrm_stack_gets_x_position_set(self):
     image_data, metadata = reader.read_xrm_stack(
         os.path.join(TEST_DIR, "test_data/test_chip00.xrm"), [0, 1])
     self.assertEqual(
         metadata["x_positions"],
         [
             715.3599853515625,
             715.3599853515625,
         ]
     )
Beispiel #8
0
 def test_read_xrm_stack_gets_theta_set(self):
     image_data, metadata = reader.read_xrm_stack(
         os.path.join(TEST_DIR, "test_data/test_chip00.xrm"), [0, 1])
     self.assertEqual(
         metadata["thetas"],
         [
             -0.06000000238418579,
             -0.06000000238418579,
         ]
     )
Beispiel #9
0
def read_aps_26id(fname, ind_tomo, ind_flat, proj=None, sino=None):
    """
    Read APS 26-ID tomography data from a stack of xrm files.
    Note: file are renamed as 
    radios/image_00000.xrm and flats/image_00000.xrm
    
    Parameters
    ----------
    fname : str
        Path to data folder name without indices and extension.

    ind_tomo : list of int, optional
        Indices of the projection files to read.

    ind_flat : list of int, optional
        Indices of the flat field files to read.

    proj : {sequence, int}, optional
        Specify projections to read. (start, end, step)

    sino : {sequence, int}, optional
        Specify sinograms to read. (start, end, step)

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3D flat field data.
    """
    fname = os.path.abspath(fname)
    tomo_name = os.path.join(fname, 'radios', 'image_00000.xrm')
    flat_name = os.path.join(fname, 'flats', 'image_00000.xrm')

    tomo = dxreader.read_xrm_stack(
        tomo_name, ind=ind_tomo, digit=5, slc=(sino, proj))
    flat = dxreader.read_xrm_stack(
        flat_name, ind=ind_flat, digit=5, slc=(sino, None))
    return tomo, flat
Beispiel #10
0
 def test_read_xrm_stack_reads_multiple_xrms(self):
     image_data, metadata = reader.read_xrm_stack(
         os.path.join(TEST_DIR, "test_data/test_chip00.xrm"), [0, 1])
     np.testing.utils.assert_(image_data is not False)
     np.testing.utils.assert_(metadata is not False)
Beispiel #11
0
 def test_read_xrm_stack_reads_multiple_xrms(self):
     image_data, metadata = reader.read_xrm_stack(
         os.path.join(TEST_DIR, "test_data/test_chip00.xrm"), [0, 1])
     np.testing.utils.assert_(image_data is not False)
     np.testing.utils.assert_(metadata is not False)