Using notebooks for inspection
In this example, we show how the results of a previous run can be loaded in a Jupyter notebook for further inspection (including any intermediate results).
To start with, we run the segmentation example pipeline.
Creating some results to work with
We first create some results to work with. We only run the task specified in examples/segmentation/task.yml and omit the sigma=2 variant:
[3]:
!command python -m repype examples/segmentation --task examples/segmentation --run
1 task(s) selected for running
(1/1) Entering task: /tmp/tmpbeholu02/examples/segmentation
Starting from scratch
(1/1) Processing: B2--W00026--P00001--Z00000--T00000--dapi.tif
Results have been stored ✅
Loading the results for inspection
We load the results that were written by the previous run of the task:
[4]:
import repype.batch
batch = repype.batch.Batch()
batch.load('examples')
batch.tasks
[4]:
{PosixPath('examples/segmentation'): <Task "examples/segmentation" 5bde8ec>,
PosixPath('examples/segmentation/sigma=2'): <Task "examples/segmentation/sigma=2" 678f085>}
[5]:
task = batch.task('examples/segmentation')
task_data = task.load()
task_data.keys()
[5]:
dict_keys(['B2--W00026--P00001--Z00000--T00000--dapi.tif'])
[6]:
pipeline_data = task_data['B2--W00026--P00001--Z00000--T00000--dapi.tif']
pipeline_data.keys()
[6]:
dict_keys(['input_id', 'image', 'segmentation'])
[7]:
imshow(pipeline_data['segmentation'])
Re-computing marginal data
Data that is marginal will be missing when loaded as shown above. To also inspect marginal data, it is necessary to run the corresponding computations:
[8]:
config = task.create_config()
task_data = task.run(config = config)
This will only run those computations which are required to compute the marginal data. Since there is no marginal data in this example, no new computations are performed, and the data is read directly from the previous run.