Closed Pawelip closed 3 years ago
Hi @Pawelip
Firs thing first: this is the TIGRE repository, not the ASTRA one, are you sure you are in the correct place?
Loading data: depends on your data format, of course.
Generally it tends to be not much harder than googling "how to load PNG numpy". This is the first link I get: https://stackoverflow.com/questions/31386096/importing-png-files-into-numpy/47044303#47044303
I'd need more information to help, of course. However, a note: TIGRE does not store [x, rotate, y] format, but [angle,v,y] format, see: https://github.com/CERN/TIGRE/issues/191#issuecomment-750699972
Yes, sorry, I am trying to use both toolboxes at the same time and thoughtlessly copied the text because I have the same problem. Data format what I have is 16bit .TIF images. The data format I have is 16 bit .TIFF images. I have no experience with python so I have a problem with the basics. So should I use the "np.array" command, and that's it ?
Ah no worries.
In a similar manner to the previous google search, replacing tiff gives the following: https://stackoverflow.com/questions/7569553/working-with-tiffs-import-export-in-python-using-numpy
Those links have examples on how to convert each image into a np.array
type. However, you will likely need to write a loop and save each image into a bigger np.array
, where each slice is an entire projection. You may or may not need to use np.transpose
to get the dimensions in the right place. Once they are loaded, I suggest you have a look at demo 21, where there are some simple suggestions on how to validate if the data is in the correct shape for TIGRE.
Note in that demo too, if these TIFF images come from a Nikon machine, TIGRE has an automatic data loader for those. If your data is from a commercially available scanner, and it has no proprietary format, I am willing to write an automatic data loader for it, so I can add it to TIGRE for free. I would need a sample dataset, of course.
If you are more brave, you can read up the source on how the Nikon data is loaded, in particular where the projections are loaded and put into a single array, after the Beer-law is applied to them (https://github.com/CERN/TIGRE/blob/master/Python/tigre/utilities/io/NikonDataLoader.py#L139-L164). I suspect the code you need is quite similar to this.
I strongly suggest taking a small python and numpy tutorial as I am sure this will not be the last time it will be useful to you :)
Yes, it is a commercial Bruker Skyscan 1172 microtomograph. I have a lot of dataset from it. I will definitely need some tutorials. I used to work a bit in matlab but that was a long time ago.
Try the data loading techniques there, particularly the NikonDataLoader bit I linked to. If the Bruker Skyscan produces datasets that are complete (i.e. produces files for projections + angles + geometry of the scanner itself) I am happy to write a loader for it. Do send me an email. If it only produces .tif files but not the rest, then there is little more to do than:
import os
import numpy
from PIL import Image
folder="your folder with the data"
whitelevel=2**16 # probably
files = sorted([file for file in os.listdir(folder) if file.lower().endswith(".tif")])
projections = []
for i in range(len(files)):
image = Image.open(os.path.join(folder, files[i]))
image = numpy.asarray(image).astype(numpy.float32)
projections.append(-numpy.log(image / float(whitelevel)))
projections=numpy.asarray(projections)
I just coded it without testing, but can't be far from this.
Of course, you will need to manually input the geometry and angles data somehow to be able to reconstruct, check the demos to understand a bit better how tigre works (first few should be enough)
Closing this issue, as this is leading to #299
Hello, I have CT data with a cone-beam tomograph. I have 900 projections with a resolution of 2000x1332 px. I have a problem with loading this data into the toolbox. Can I ask you for an example how to use eg. numpy to create a matrix [x, rotate, y] so that I can use it in ASTRA?