Using tractography function in pipeline to generate structure tensors

Import the main analysis module and tractography module. Use the analysis module to download a raw brain of interest, then use the tractography function "nii_to_tiff_stack" to save a .nii as a TIFF stack.


In [1]:
import tractography as tract

In [2]:
import analysis3 as a3

In [3]:
output = a3.get_raw_brain("s275", "userToken.pem", save = True)

In [4]:
tract.nii_to_tiff_stack("s275_raw.nii", "s275")

In [5]:
data = tract.tiff_stack_to_array("s275_TIFFs/")


(62, 51, 1114)

From there, run the generate_FSL_structure_tensor code to save a copy of the FSL structure tensor.

Note that the value can also be directly used from the function.


In [6]:
tract.generate_FSL_structure_tensor(data, "s275")


Start DoG Sigma on 1
Start Gauss Sigma with gausigma = 2.3
Generating Gaussian kernel...
Blurring gradient products...
Saving a copy for this Gaussian sigma...
Completed computing structure tensor on s275!
Out[6]:
array([[[[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        ..., 
        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]]],


       [[[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        ..., 
        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]]],


       [[[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        ..., 
        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]]],


       ..., 
       [[[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  1,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  1,  1,  0,  0,  0],
         [ 0,  1,  1,  0,  1,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        ..., 
        [[ 0,  0, 25,  0, 32,  1],
         [ 0,  0, 33,  0, 41,  1],
         [ 1,  0, 39,  1, 47,  1],
         ..., 
         [ 0,  0, 10,  0,  8,  1],
         [ 0,  0,  6,  0,  5,  0],
         [ 0,  0,  4,  0,  3,  0]],

        [[ 0,  0, 16,  0, 23,  1],
         [ 0,  0, 22,  0, 29,  1],
         [ 0,  0, 26,  0, 34,  1],
         ..., 
         [ 0,  0,  7,  0,  6,  0],
         [ 0,  0,  4,  0,  3,  0],
         [ 0,  0,  2,  0,  2,  0]],

        [[ 0,  0,  9,  0, 15,  0],
         [ 0,  0, 13,  0, 19,  0],
         [ 0,  0, 16,  0, 22,  0],
         ..., 
         [ 0,  0,  4,  0,  4,  0],
         [ 0,  0,  2,  0,  2,  0],
         [ 0,  0,  1,  0,  1,  0]]],


       [[[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  1,  1,  0,  0,  0],
         [ 0,  1,  1,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        ..., 
        [[ 0,  0, 19,  0, 23,  1],
         [ 0,  0, 25,  0, 29,  1],
         [ 0,  0, 29,  0, 34,  1],
         ..., 
         [ 0,  0,  8,  0,  5,  0],
         [ 0,  0,  5,  0,  3,  0],
         [ 0,  0,  3,  0,  2,  0]],

        [[ 0,  0, 12,  0, 16,  0],
         [ 0,  0, 16,  0, 20,  0],
         [ 0,  0, 19,  0, 23,  0],
         ..., 
         [ 0,  0,  5,  0,  4,  0],
         [ 0,  0,  3,  0,  2,  0],
         [ 0,  0,  1,  0,  1,  0]],

        [[ 0,  0,  6,  0, 10,  0],
         [ 0,  0,  9,  0, 13,  0],
         [ 0,  0, 11,  0, 15,  0],
         ..., 
         [ 0,  0,  3,  0,  3,  0],
         [ 0,  0,  2,  0,  2,  0],
         [ 0,  0,  1,  0,  1,  0]]],


       [[[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        [[ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  1,  1,  0,  0,  0],
         ..., 
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0],
         [ 0,  0,  0,  0,  0,  0]],

        ..., 
        [[ 0,  0, 13,  0, 14,  0],
         [ 0,  0, 17,  0, 19,  0],
         [ 0,  0, 20,  0, 22,  0],
         ..., 
         [ 0,  0,  5,  0,  3,  0],
         [ 0,  0,  3,  0,  2,  0],
         [ 0,  0,  2,  0,  1,  0]],

        [[ 0,  0,  8,  0, 10,  0],
         [ 0,  0, 10,  0, 13,  0],
         [ 0,  0, 12,  0, 15,  0],
         ..., 
         [ 0,  0,  3,  0,  2,  0],
         [ 0,  0,  2,  0,  1,  0],
         [ 0,  0,  1,  0,  1,  0]],

        [[ 0,  0,  4,  0,  6,  0],
         [ 0,  0,  6,  0,  8,  0],
         [ 0,  0,  7,  0,  9,  0],
         ..., 
         [ 0,  0,  2,  0,  2,  0],
         [ 0,  0,  1,  0,  1,  0],
         [ 0,  0,  1,  0,  0,  0]]]], dtype=uint8)

In [ ]: