MathOnco / valis

Virtual Alignment of pathoLogy Image Series
https://valis.readthedocs.io/en/latest/
MIT License
122 stars 29 forks source link

error calling register on 2 svs files #35

Open idc9 opened 1 year ago

idc9 commented 1 year ago

valis looks like an awesome package! I've just started trying to use it and am running into an error.

Calling the following code

registrar = Valis(src_dir='path/to/dir/with/2/svs/files', dst_dir='another/dir')
rigid_registrar, non_rigid_registrar, error_df = registrar.register()

returns the following warnings + error

JVM has been initialized. Be sure to call registration.kill_jvm() or slide_io.kill_jvm() at the end of your script.

(process:20488): GLib-CRITICAL **: 16:58:31.015: g_datalist_id_set_data_full: assertion 'key_id > 0' failed

(process:20488): GLib-GObject-CRITICAL **: 16:58:31.015: g_param_spec_pool_lookup: assertion 'pool != NULL' failed

(process:20488): GLib-GObject-WARNING **: 16:58:31.015: g_object_set_is_valid_property: object class '(null)' has no property named 'filename'
/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/valis/valtils.py:75: UserWarning: unable to call VipsForeignLoadOpenslideFile
  openslideload: parameter filename not set

  warnings.warn(warning_msg, warning_type)

(process:20488): GLib-CRITICAL **: 16:58:31.020: g_datalist_id_set_data_full: assertion 'key_id > 0' failed

(process:20488): GLib-GObject-CRITICAL **: 16:58:31.020: g_param_spec_pool_lookup: assertion 'pool != NULL' failed

(process:20488): GLib-GObject-WARNING **: 16:58:31.020: g_object_set_is_valid_property: object class '(null)' has no property named 'filename'
/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/valis/valtils.py:75: UserWarning: unable to call VipsForeignLoadOpenslideFile
  openslideload: parameter filename not set

  warnings.warn(warning_msg, warning_type)

==== Converting images

  0%|                                                     | 0/2 [00:00<?, ?it/s]
(process:20488): GLib-CRITICAL **: 16:58:31.080: g_datalist_id_set_data_full: assertion 'key_id > 0' failed

(process:20488): GLib-GObject-CRITICAL **: 16:58:31.080: g_param_spec_pool_lookup: assertion 'pool != NULL' failed

(process:20488): GLib-GObject-WARNING **: 16:58:31.080: g_object_set_is_valid_property: object class '(null)' has no property named 'filename'
/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/valis/valtils.py:75: UserWarning: unable to call VipsForeignLoadOpenslideFile
  openslideload: parameter filename not set

  warnings.warn(warning_msg, warning_type)

(process:20488): GLib-CRITICAL **: 16:58:31.084: g_datalist_id_set_data_full: assertion 'key_id > 0' failed

(process:20488): GLib-GObject-CRITICAL **: 16:58:31.084: g_param_spec_pool_lookup: assertion 'pool != NULL' failed

(process:20488): GLib-GObject-WARNING **: 16:58:31.084: g_object_set_is_valid_property: object class '(null)' has no property named 'filename'
No series provided. Selecting series with largest image, which is series 0
Converting slide to pyvips image

100%|███████████████████████████████████████████| 2/2 [00:00<00:00, 8895.66it/s]

(process:20488): GLib-GObject-WARNING **: 16:58:32.557: cannot retrieve class for invalid (unclassed) type '<invalid>'

(process:20488): GLib-GObject-WARNING **: 16:58:32.557: cannot retrieve class for invalid (unclassed) type '<invalid>'
  0%|                                                     | 0/2 [00:01<?, ?it/s]
/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/valis/valtils.py:75: UserWarning: no value uchar in gtype NULL (0)

  warnings.warn(warning_msg, warning_type)
Traceback (most recent call last):
  File "/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/valis/registration.py", line 3364, in register
    self.convert_imgs(series=self.series, reader_cls=reader_cls)
  File "/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/valis/registration.py", line 1831, in convert_imgs
    vips_img = reader.slide2vips(level=level)
  File "/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/valis/slide_io.py", line 939, in slide2vips
    self.get_tiles_parallel(level, tile_bbox, pixel_type, series),
  File "/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/valis/slide_io.py", line 878, in get_tiles_parallel
    Parallel()(delayed(tile2vips_threaded)(i) for i in tqdm(range(n_tiles)))
  File "/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/joblib/parallel.py", line 1056, in __call__
    self.retrieve()
  File "/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/joblib/parallel.py", line 935, in retrieve
    self._output.extend(job.get(timeout=self.timeout))
  File "/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
  File "/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/joblib/_parallel_backends.py", line 595, in __call__
    return self.func(*args, **kwargs)
  File "/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/joblib/parallel.py", line 262, in __call__
    return [func(*args, **kwargs)
  File "/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/joblib/parallel.py", line 262, in <listcomp>
    return [func(*args, **kwargs)
  File "/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/valis/slide_io.py", line 874, in tile2vips_threaded
    tile_array[idx] = slide_tools.numpy2vips(tile, self.metadata.pyvips_interpretation)
  File "/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/valis/slide_tools.py", line 92, in numpy2vips
    vi = pyvips.Image.new_from_memory(linear.data, width, height, bands,
  File "/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/pyvips/vimage.py", line 351, in new_from_memory
    format_value = GValue.to_enum(GValue.format_type, format)
  File "/Users/iaincarmichael/anaconda3/envs/comp_onc/lib/python3.8/site-packages/pyvips/gvalue.py", line 110, in to_enum
    raise Error('no value {0} in gtype {1} ({2})'.
pyvips.error.Error: no value uchar in gtype NULL (0)

JVM has been killed. If this was due to an error, then a new Python session will need to be started

I'm using python 3.8 and valis version 1.0.0rc12.

cdgatenbee commented 1 year ago

Hi @idc9, Glad to hear valis could be useful package for you :) Regarding this error, is it only with certain svs files, or all svs files you've tried? The error looks like it might have something to do with not being able to read the svs images, but valis should be able to do this, since it uses Openslide (via pyvips/libvips) or Bio-formats to read images, and I'm able to open svs files successfully on my laptop. Could you check your libvips version, and do you know if it was installed with OpenSlide support? Also, maybe you could try your code using the docker image (available here ) which has been tested with svs files.

Best, -Chandler