rivuletpy icon indicating copy to clipboard operation
rivuletpy copied to clipboard

ModuleNotFoundError: No module named 'msfm'

Open meliamne opened this issue 2 years ago • 1 comments
trafficstars

Dear dev,

I installed the library in a fresh conda env as suggested and pip installed rivuletpy from both pip and github. After the installation, the rtrace command cannot be found by the system. Running either the quicktest or the rtrace app from the github repo reports ModuleNotFoundError: No module named 'msfm'.

Do you have any idea what the issue could be?

Kind regards.

#Python 3.9.16 #pip list

Package             Version
------------------- ---------
contourpy           1.0.7
cycler              0.11.0
Cython              0.29.33
fonttools           4.38.0
imageio             2.26.0
importlib-resources 5.12.0
kiwisolver          1.4.4
matplotlib          3.7.0
networkx            3.0
nibabel             4.0.2
numpy               1.24.2
packaging           23.0
Pillow              9.4.0
pip                 23.0.1
pyglet              1.5.27
pylibtiff           0.4.4
pyparsing           3.0.9
python-dateutil     2.8.2
PyWavelets          1.4.1
rivuletpy           0.3.0
scikit-fmm          2022.8.15
scikit-image        0.19.3
scipy               1.10.1
setuptools          67.4.0
SimpleITK           2.2.1
six                 1.16.0
tifffile            2023.2.27
tqdm                4.64.1
wheel               0.38.4
zipp                3.15.0

meliamne avatar Feb 28 '23 16:02 meliamne

Hi @meliamne. This is happening because the msfm package isn't being compiled properly for some reason.

The most immediate fix is to remove the import msfm call at the top of the module, and only be imported if using quality=True for R2Tracer.

So this:

    def _fast_marching(self):
        speed = self._make_speed()

        # # Fast Marching
        if self._quality:

            # if not self._silent: print('--MSFM...')
            self._t = msfm.run(speed, self._bimg.copy().astype(
                'int64'), self._soma.centroid, True, True)
        else:
            # if not self._silent: print('--FM...')
            marchmap = np.ones(self._bimg.shape)
            marchmap[self._soma.centroid[0],
                     self._soma.centroid[1], self._soma.centroid[2]] = -1
            self._t = skfmm.travel_time(marchmap, speed, dx=5e-3)

should be changed to this:

  def _fast_marching(self):
        speed = self._make_speed()

        # # Fast Marching
        if self._quality:
            # only import msfm if quality = True
            import msfm 

            # if not self._silent: print('--MSFM...')
            self._t = msfm.run(speed, self._bimg.copy().astype(
                'int64'), self._soma.centroid, True, True)
        else:
            # if not self._silent: print('--FM...')
            marchmap = np.ones(self._bimg.shape)
            marchmap[self._soma.centroid[0],
                     self._soma.centroid[1], self._soma.centroid[2]] = -1
            self._t = skfmm.travel_time(marchmap, speed, dx=5e-3)

kpeez avatar Apr 04 '23 21:04 kpeez