FlatField: TypeError: 'NoneType' object is not subscriptable
update_dataset_info_flats_darks
fails if
- The program is launched within the same directory as the NX file
-
update_dataset_info_flats_darks()
is called with RELATIVE path for the NX file
Example:
from nabu.resources.dataset_analyzer import analyze_dataset
from nabu.resources.nxflatfield import update_dataset_info_flats_darks
di = analyze_dataset("my_dataset.nx")
update_dataset_info_flats_darks(di, True)
The error is
Traceback (most recent call last)
3 from nabu.resources.nxflatfield import update_dataset_info_flats_darks
4 di = analyze_dataset("/data/scisofttmp/mirone/aspect_retrieval/stages_mouton/orig/all_stages/HA-1100_27.73um_sheep-head_ethanol_W__0000_0001.nx")
----> 5 update_dataset_info_flats_darks(di, 1)
6 b = 1
File ~/tmp/nabu_test/nabu/resources/nxflatfield.py:195, in update_dataset_info_flats_darks(dataset_info, flatfield_mode, output_dir, darks_flats_dir)
192 if all(frames_saved.values()):
193 break
--> 195 dataset_info.flats = frames_urls["flats"][0] # reduced_frames["flats"] # in future versions
196 dataset_info.flats_srcurrent = frames_urls["flats"][1].machine_electric_current
197 # This is an extra check to avoid having more than 1 (reduced) dark.
198 # FlatField only works with exactly 1 (reduced) dark (having more than 1 series of darks makes little sense)
199 # This is normally prevented by tomoscan HDF5FramesReducer, but let's add this extra check
TypeError: 'NoneType' object is not subscriptable
Not sure it should be fixed. The simplest would be to sanitize the NX path (eg. use os.path.abspath
). Alternative would be to do os.path.dirname() or "."
in many places.
Edited by Pierre Paleo