In [1]:
import requests
from tqdm import tqdm_notebook as tqdm
import os

from itkwidgets import view

import itk
In [2]:
# Download example data
def download_data(url, filename):
    if not os.path.exists(filename):
        chunk_size = 32 * 1024
        r = requests.get(url, stream=True)
        total_size = int(r.headers.get('content-length', 0))
        pbar = tqdm(unit="B", unit_scale=True, total=int(total_size))
        with open(filename, 'wb') as f:
            for chunk in r.iter_content(chunk_size=chunk_size): 
                if chunk: # filter out keep-alive new chunks
                    pbar.update(len(chunk))
                    f.write(chunk)
                    
file_name = 'C0004255.ISQ'
file_url = 'https://data.kitware.com/api/v1/file/591e56178d777f16d01e0d20/download'
download_data(file_url, file_name)
In [3]:
ImageType = itk.Image[itk.ctype('signed short'), 3]
reader = itk.ImageFileReader[ImageType].New()
imageio = itk.ScancoImageIO.New()
reader.SetImageIO(imageio)
reader.SetFileName(file_name)
reader.Update()
In [4]:
view(reader.GetOutput())
In [5]:
print(imageio.GetEnergy())
45.0
In [6]:
print(imageio.GetIntensity())
0.177
In [7]:
print(imageio.GetNumberOfProjections())
500