bkntr / napari-brainways

Brainways UI plugin for napari
GNU General Public License v3.0
6 stars 0 forks source link

Image file type? #1

Closed AllisonMcDonald closed 3 weeks ago

AllisonMcDonald commented 12 months ago

Hello,

I'm very interested in this software, and excited to see it's now available!

What file type are the images/channels supposed to be? I have tried adding slide images to a New Subject, and none of the formats I've tried could be loaded (ome-tiff, tiff, zip folder with tiffs, qptiff).

Error codes: TypeError: object of type 'ValueError' has no len() UserWarning: Could not parse OME metadata from ... Could not parse XML from b'ImageJ=\nhyperstack=true\nimages=2\nchannels=2\nslices=1\nframes=1'!

Thanks so much, and really looking forward to this software's progress.

Allison

bkntr commented 12 months ago

Hello Allison, thank you for showing interest in Brainways! Under the hood, Brainways uses the very sophisticated image reading mechanism of QuPath. Could you please try and open the same file in QuPath and see if it works? In my experience, QuPath supports almost any image file type you can imagine, including tiff and ome-tiff, but not a zip folder.

Let me know how it goes.

Best wishes, Ben

---------- Forwarded message --------- מאת: Allison McDonald @.> ‪Date: יום א׳, 10 בספט׳ 2023 ב-15:52‬ Subject: [bkntr/napari-brainways] Image file type? (Issue #1) To: bkntr/napari-brainways @.> Cc: Subscribed @.***>

Hello,

I'm very interested in this software, and excited to see it's now available!

What file type are the images/channels supposed to be? I have tried adding slide images to a New Subject, and none of the formats I've tried could be loaded (ome-tiff, tiff, zip folder with tiffs, qptiff).

Error codes: TypeError: object of type 'ValueError' has no len() UserWarning: Could not parse OME metadata from ... Could not parse XML from b'ImageJ=\nhyperstack=true\nimages=2\nchannels=2\nslices=1\nframes=1'!

Thanks so much, and really looking forward to this software's progress.

Allison

— Reply to this email directly, view it on GitHub https://github.com/bkntr/napari-brainways/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGY2OWV6J7ZLWZEYSJWSF3XZWZZVANCNFSM6AAAAAA4SFADBA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

AllisonMcDonald commented 12 months ago

Hi Ben, Thanks for you quick response!

The images do open on qupath (both ome.tiff or .tiff). Now, based on the Error codes, I think it's actually having trouble accessing qupath, when trying to add a file to a subject.

When I run napari, start a new project (rat atlas), add a subject, and try to add any types of files, I receive the following error below. It looks like it's regarding the folder naming conventions? (ValueError("destination: 'C:\\Users\\a.mcdonald\\.brainways\\qupath' is not a directory"))

Thanks so much, I really look forward to moving forward with brainways! Allison

(base) C:\>conda activate brainways-new

(brainways-new) C:\>napari
# extracting: C:\Users\a.mcdonald\.brainways\QuPath-0.4.3-Windows.zip
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~\AppData\Local\anaconda3\envs\brainways-new\lib\site-packages\superqt\utils\_qthreading.py:617, in create_worker.<locals>.reraise(e=ValueError("destination: 'C:\\\\Users\\\\a.mcdonald\\\\.brainways\\\\qupath' is not a directory"))
    616 def reraise(e):
--> 617     raise e
        e = ValueError("destination: 'C:\\\\Users\\\\a.mcdonald\\\\.brainways\\\\qupath' is not a directory")

File ~\AppData\Local\anaconda3\envs\brainways-new\lib\site-packages\superqt\utils\_qthreading.py:178, in WorkerBase.run(self=<napari._qt.qthreading.GeneratorWorker object>)
    176     warnings.filterwarnings("always")
    177     warnings.showwarning = lambda *w: self.warned.emit(w)
--> 178     result = self.work()
        self = <napari._qt.qthreading.GeneratorWorker object at 0x000001A7B44D9310>
    179 if isinstance(result, Exception):
    180     if isinstance(result, RuntimeError):
    181         # The Worker object has likely been deleted.
    182         # A deleted wrapped C/C++ object may result in a runtime
    183         # error that will cause segfault if we try to do much other
    184         # than simply notify the user.

File ~\AppData\Local\anaconda3\envs\brainways-new\lib\site-packages\superqt\utils\_qthreading.py:444, in GeneratorWorker.work(self=<napari._qt.qthreading.GeneratorWorker object>)
    442 try:
    443     _input = self._next_value()
--> 444     output = self._gen.send(_input)
        self = <napari._qt.qthreading.GeneratorWorker object at 0x000001A7B44D9310>
        _input = None
        self._gen = <generator object CreateSubjectDialog.add_filenames_async.<locals>.work at 0x000001A793E33DD0>
    445     self.yielded.emit(output)
    446 except StopIteration as exc:

File ~\AppData\Local\anaconda3\envs\brainways-new\lib\site-packages\napari_brainways\widgets\create_subject_dialog.py:156, in CreateSubjectDialog.add_filenames_async.<locals>.work()
    154         self.subject.documents.remove(document)
    155     return []
--> 156 for scene in range(len(get_scenes(filename))):
        filename = '//vumc.nl/home$/isilon/a.mcdonald/a.mcdonald/Desktop/NAcSh-cFos_brainways/EtOH06all_R01-01_Scan1_s001.ome.tif'
    157     documents.append(
    158         self.subject.add_image(
    159             ImagePath(filename=filename, scene=scene),
    160             load_thumbnail=False,
    161         )
    162     )
    163 yield

File ~\AppData\Local\anaconda3\envs\brainways-new\lib\site-packages\brainways\utils\io_utils\readers\__init__.py:20, in get_scenes(filename='//vumc.nl/home$/isilon/a.mcdonald/a.mcdonald/Des...Fos_brainways/EtOH06all_R01-01_Scan1_s001.ome.tif')
     19 def get_scenes(filename: Union[str, Path]):
---> 20     reader = QupathReader(filename)
        QupathReader = <class 'brainways.utils.io_utils.readers.qupath_reader.QupathReader'>
        filename = '//vumc.nl/home$/isilon/a.mcdonald/a.mcdonald/Desktop/NAcSh-cFos_brainways/EtOH06all_R01-01_Scan1_s001.ome.tif'
     21     return reader.scenes

File ~\AppData\Local\anaconda3\envs\brainways-new\lib\site-packages\brainways\utils\io_utils\readers\qupath_reader.py:68, in QupathReader.__init__(self=<QupathReader [Image-is-in-Memory: False]>, image='//vumc.nl/home$/isilon/a.mcdonald/a.mcdonald/Des...Fos_brainways/EtOH06all_R01-01_Scan1_s001.ome.tif', fs_kwargs=None)
     66 def __init__(self, image: PathLike, *, fs_kwargs: Dict[str, Any] = None):
     67     super().__init__(image)
---> 68     QupathReader._initialize_qupath()
        QupathReader = <class 'brainways.utils.io_utils.readers.qupath_reader.QupathReader'>
     69     self._fs, self._path = io_utils.pathlike_to_fs(
     70         image,
     71         enforce_exists=True,
     72         fs_kwargs=fs_kwargs or {},
     73     )
     74     self._current_level = 0

File ~\AppData\Local\anaconda3\envs\brainways-new\lib\site-packages\brainways\utils\io_utils\readers\qupath_reader.py:41, in QupathReader._initialize_qupath()
     39 # TODO: move this code to some init function inside QupathReader
     40 if not is_qupath_downloaded(QupathReader._qupath_version):
---> 41     download_qupath()
     42 from paquo._logging import redirect
     43 from paquo.java import BufferedImage, ImageServerProvider, JClass, String

File ~\AppData\Local\anaconda3\envs\brainways-new\lib\site-packages\brainways\utils\qupath.py:82, in download_qupath(install_path=WindowsPath('C:/Users/a.mcdonald/.brainways/qupath'), version='0.4.3', system='Windows', download_path=WindowsPath('C:/Users/a.mcdonald/.brainways'), ssl_verify=False)
     74 file = download_qupath(
     75     version,
     76     path=download_path,
   (...)
     79     ssl_verify=ssl_verify,
     80 )
     81 print("# extracting:", file)
---> 82 app = extract_qupath(file, install_path, system=system)
        file = 'C:\\Users\\a.mcdonald\\.brainways\\QuPath-0.4.3-Windows.zip'
        install_path = WindowsPath('C:/Users/a.mcdonald/.brainways/qupath')
        system = 'Windows'
     83 print("# available at:", app)
     85 print("#\n# use via environment variable:")

File ~\AppData\Local\anaconda3\envs\brainways-new\lib\site-packages\paquo\_utils.py:213, in extract_qupath(file=r'C:\Users\a.mcdonald\.brainways\QuPath-0.4.3-Windows.zip', destination=r'C:\Users\a.mcdonald\.brainways\qupath', system='Windows')
    211 destination = os.path.abspath(os.path.expanduser(destination))
    212 if not os.path.isdir(destination):
--> 213     raise ValueError(f"destination: {destination!r} is not a directory")
    214 qp_dst = os.path.join(destination, app_dir)
    215 if os.path.isdir(qp_dst):

ValueError: destination: 'C:\\Users\\a.mcdonald\\.brainways\\qupath' is not a directory
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~\AppData\Local\anaconda3\envs\brainways-new\lib\site-packages\napari_brainways\widgets\create_subject_dialog.py:143, in CreateSubjectDialog.add_filenames_async.<locals>.on_work_returned(documents=ValueError("destination: 'C:\\\\Users\\\\a.mcdonald\\\\.brainways\\\\qupath' is not a directory"))
    141 def on_work_returned(documents: List[SliceInfo]):
    142     progress.close()
--> 143     self.add_document_rows_async(documents)
        documents = ValueError("destination: 'C:\\\\Users\\\\a.mcdonald\\\\.brainways\\\\qupath' is not a directory")
        self = <napari_brainways.widgets.create_subject_dialog.CreateSubjectDialog object at 0x000001A7B44D9790>

File ~\AppData\Local\anaconda3\envs\brainways-new\lib\site-packages\napari_brainways\widgets\create_subject_dialog.py:204, in CreateSubjectDialog.add_document_rows_async(self=<napari_brainways.widgets.create_subject_dialog.CreateSubjectDialog object>, documents=ValueError("destination: 'C:\\\\Users\\\\a.mcdonald\\\\.brainways\\\\qupath' is not a directory"), select_document_index=None)
    200 def add_document_rows_async(
    201     self, documents: List[SliceInfo], select_document_index: Optional[int] = None
    202 ) -> FunctionWorker:
    203     progress = QProgressDialog(
--> 204         "Opening images...", "Cancel", 0, len(documents), self
        QProgressDialog = <class 'PyQt5.QtWidgets.QProgressDialog'>
        self = <napari_brainways.widgets.create_subject_dialog.CreateSubjectDialog object at 0x000001A7B44D9790>
        documents = ValueError("destination: 'C:\\\\Users\\\\a.mcdonald\\\\.brainways\\\\qupath' is not a directory")
    205     )
    206     progress.setModal(True)
    207     progress.setValue(0)

TypeError: object of type 'ValueError' has no len()
bkntr commented 11 months ago

Hi Allison, could you please try to delete the following directory and try again: C:\Users\a.mcdonald\.brainways\

AllisonMcDonald commented 11 months ago

Hey Ben, It results in the same error, I'm afraid.

(base) C:\>conda activate napari-brainways

(napari-brainways) C:\>napari
# downloading: https://github.com/qupath/qupath/releases/download/v0.4.3/QuPath-0.4.3-Windows.zip
# progress ....................... OK
# extracting: C:\Users\a.mcdonald\.brainways\QuPath-0.4.3-Windows.zip
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~\AppData\Local\anaconda3\envs\napari-brainways\lib\site-packages\superqt\utils\_qthreading.py:617, in create_worker.<locals>.reraise(e=ValueError("destination: 'C:\\\\Users\\\\a.mcdonald\\\\.brainways\\\\qupath' is not a directory"))
    616 def reraise(e):
--> 617     raise e
        e = ValueError("destination: 'C:\\\\Users\\\\a.mcdonald\\\\.brainways\\\\qupath' is not a directory")

File ~\AppData\Local\anaconda3\envs\napari-brainways\lib\site-packages\superqt\utils\_qthreading.py:178, in WorkerBase.run(self=<napari._qt.qthreading.GeneratorWorker object>)
    176     warnings.filterwarnings("always")
    177     warnings.showwarning = lambda *w: self.warned.emit(w)
--> 178     result = self.work()
        self = <napari._qt.qthreading.GeneratorWorker object at 0x000001B27D1B7DC0>
    179 if isinstance(result, Exception):
    180     if isinstance(result, RuntimeError):
    181         # The Worker object has likely been deleted.
    182         # A deleted wrapped C/C++ object may result in a runtime
    183         # error that will cause segfault if we try to do much other
    184         # than simply notify the user.

File ~\AppData\Local\anaconda3\envs\napari-brainways\lib\site-packages\superqt\utils\_qthreading.py:444, in GeneratorWorker.work(self=<napari._qt.qthreading.GeneratorWorker object>)
    442 try:
    443     _input = self._next_value()
--> 444     output = self._gen.send(_input)
        self = <napari._qt.qthreading.GeneratorWorker object at 0x000001B27D1B7DC0>
        _input = None
        self._gen = <generator object CreateSubjectDialog.add_filenames_async.<locals>.work at 0x000001B20096A9E0>
    445     self.yielded.emit(output)
    446 except StopIteration as exc:

File ~\AppData\Local\anaconda3\envs\napari-brainways\lib\site-packages\napari_brainways\widgets\create_subject_dialog.py:156, in CreateSubjectDialog.add_filenames_async.<locals>.work()
    154         self.subject.documents.remove(document)
    155     return []
--> 156 for scene in range(len(get_scenes(filename))):
        filename = '//vumc.nl/home$/isilon/a.mcdonald/a.mcdonald/Desktop/NAcSh-cFos_brainways/EtOH06all_R01-01_Scan1_s001.ome.tif'
    157     documents.append(
    158         self.subject.add_image(
    159             ImagePath(filename=filename, scene=scene),
    160             load_thumbnail=False,
    161         )
    162     )
    163 yield

File ~\AppData\Local\anaconda3\envs\napari-brainways\lib\site-packages\brainways\utils\io_utils\readers\__init__.py:20, in get_scenes(filename='//vumc.nl/home$/isilon/a.mcdonald/a.mcdonald/Des...Fos_brainways/EtOH06all_R01-01_Scan1_s001.ome.tif')
     19 def get_scenes(filename: Union[str, Path]):
---> 20     reader = QupathReader(filename)
        QupathReader = <class 'brainways.utils.io_utils.readers.qupath_reader.QupathReader'>
        filename = '//vumc.nl/home$/isilon/a.mcdonald/a.mcdonald/Desktop/NAcSh-cFos_brainways/EtOH06all_R01-01_Scan1_s001.ome.tif'
     21     return reader.scenes

File ~\AppData\Local\anaconda3\envs\napari-brainways\lib\site-packages\brainways\utils\io_utils\readers\qupath_reader.py:68, in QupathReader.__init__(self=<QupathReader [Image-is-in-Memory: False]>, image='//vumc.nl/home$/isilon/a.mcdonald/a.mcdonald/Des...Fos_brainways/EtOH06all_R01-01_Scan1_s001.ome.tif', fs_kwargs=None)
     66 def __init__(self, image: PathLike, *, fs_kwargs: Dict[str, Any] = None):
     67     super().__init__(image)
---> 68     QupathReader._initialize_qupath()
        QupathReader = <class 'brainways.utils.io_utils.readers.qupath_reader.QupathReader'>
     69     self._fs, self._path = io_utils.pathlike_to_fs(
     70         image,
     71         enforce_exists=True,
     72         fs_kwargs=fs_kwargs or {},
     73     )
     74     self._current_level = 0

File ~\AppData\Local\anaconda3\envs\napari-brainways\lib\site-packages\brainways\utils\io_utils\readers\qupath_reader.py:41, in QupathReader._initialize_qupath()
     39 # TODO: move this code to some init function inside QupathReader
     40 if not is_qupath_downloaded(QupathReader._qupath_version):
---> 41     download_qupath()
     42 from paquo._logging import redirect
     43 from paquo.java import BufferedImage, ImageServerProvider, JClass, String

File ~\AppData\Local\anaconda3\envs\napari-brainways\lib\site-packages\brainways\utils\qupath.py:82, in download_qupath(install_path=WindowsPath('C:/Users/a.mcdonald/.brainways/qupath'), version='0.4.3', system='Windows', download_path=WindowsPath('C:/Users/a.mcdonald/.brainways'), ssl_verify=False)
     74 file = download_qupath(
     75     version,
     76     path=download_path,
   (...)
     79     ssl_verify=ssl_verify,
     80 )
     81 print("# extracting:", file)
---> 82 app = extract_qupath(file, install_path, system=system)
        file = 'C:\\Users\\a.mcdonald\\.brainways\\QuPath-0.4.3-Windows.zip'
        install_path = WindowsPath('C:/Users/a.mcdonald/.brainways/qupath')
        system = 'Windows'
     83 print("# available at:", app)
     85 print("#\n# use via environment variable:")

File ~\AppData\Local\anaconda3\envs\napari-brainways\lib\site-packages\paquo\_utils.py:213, in extract_qupath(file=r'C:\Users\a.mcdonald\.brainways\QuPath-0.4.3-Windows.zip', destination=r'C:\Users\a.mcdonald\.brainways\qupath', system='Windows')
    211 destination = os.path.abspath(os.path.expanduser(destination))
    212 if not os.path.isdir(destination):
--> 213     raise ValueError(f"destination: {destination!r} is not a directory")
    214 qp_dst = os.path.join(destination, app_dir)
    215 if os.path.isdir(qp_dst):

ValueError: destination: 'C:\\Users\\a.mcdonald\\.brainways\\qupath' is not a directory
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~\AppData\Local\anaconda3\envs\napari-brainways\lib\site-packages\napari_brainways\widgets\create_subject_dialog.py:143, in CreateSubjectDialog.add_filenames_async.<locals>.on_work_returned(documents=ValueError("destination: 'C:\\\\Users\\\\a.mcdonald\\\\.brainways\\\\qupath' is not a directory"))
    141 def on_work_returned(documents: List[SliceInfo]):
    142     progress.close()
--> 143     self.add_document_rows_async(documents)
        documents = ValueError("destination: 'C:\\\\Users\\\\a.mcdonald\\\\.brainways\\\\qupath' is not a directory")
        self = <napari_brainways.widgets.create_subject_dialog.CreateSubjectDialog object at 0x000001B27D1B79D0>

File ~\AppData\Local\anaconda3\envs\napari-brainways\lib\site-packages\napari_brainways\widgets\create_subject_dialog.py:204, in CreateSubjectDialog.add_document_rows_async(self=<napari_brainways.widgets.create_subject_dialog.CreateSubjectDialog object>, documents=ValueError("destination: 'C:\\\\Users\\\\a.mcdonald\\\\.brainways\\\\qupath' is not a directory"), select_document_index=None)
    200 def add_document_rows_async(
    201     self, documents: List[SliceInfo], select_document_index: Optional[int] = None
    202 ) -> FunctionWorker:
    203     progress = QProgressDialog(
--> 204         "Opening images...", "Cancel", 0, len(documents), self
        QProgressDialog = <class 'PyQt5.QtWidgets.QProgressDialog'>
        self = <napari_brainways.widgets.create_subject_dialog.CreateSubjectDialog object at 0x000001B27D1B79D0>
        documents = ValueError("destination: 'C:\\\\Users\\\\a.mcdonald\\\\.brainways\\\\qupath' is not a directory")
    205     )
    206     progress.setModal(True)
    207     progress.setValue(0)

TypeError: object of type 'ValueError' has no len()
bkntr commented 11 months ago

Sorry for the late reply as I am currently in a vacation until October 22nd with limited availability. If you can, please try to delete the directory again, and send here the error log of the first time you try to open an image in Brainways. There seems to be a problem with downloading and extracting QuPath to your home directory. Maybe there's not enough space in your hard drive?