ppsp-team / HyPyP

The Hyperscanning Python Pipeline
BSD 3-Clause "New" or "Revised" License
75 stars 42 forks source link

Error for importing 3D headmodel #22

Closed aayrolles closed 4 years ago

aayrolles commented 4 years ago

if it reports an error regarding obj missing when plotting 3D inter-brain connectivity, try to move “data/Basehead.obj” to "C:\ProgramData\Miniconda3\Lib\site-packages\"

aayrolles commented 4 years ago

Here the error @ufangyang gets, we check, the headmodel data are in the good repository and the link work for the epoch file Capture d’écran 2020-06-26 à 10 25 32

deep-introspection commented 4 years ago

This is coming from os.pardir i.e. ".." in the path. The problem is that the __file__ position and the data folder are not relatively placed similarly as in the Github repository structure.

For the epochs, how does os.path.join(...) look like?

aayrolles commented 4 years ago

Here are the both path :

mesh = meshio.read(os.path.join(os.path.dirname(__file__), os.pardir,'data',"Basehead.obj"))

epo1 = mne.read_epochs( os.path.join(os.path.dirname(__file__), os.pardir, "data", "participant1-epo.fif"), preload=True, )

aayrolles commented 4 years ago

Maybe it comes from the ' ' instead of " "?

deep-introspection commented 4 years ago

'' vs "" shouldn't have an impact in Python.

Maybe this is the read function of meshio that does not like .. in the path. Try to check how MNE read_epochs is handling the string of characters. Maybe they have a function transforming /A/B/../C/ into /A/C/

YannBeauxis commented 4 years ago

You should use pathlib ilbrary with Path.resolve() method.

In general I prefer pathlib.Path rather than os.path ;)

aayrolles commented 4 years ago

Thanks Yann ! I change it for mesh = meshio.read(Path('../data/Basehead.obj').resolve()) It should work better now

ufangYang commented 4 years ago

The problem has been solved for me only if I specify the path for Basehead.obj in the getting_started script.

Below is the piece of code in getting_started that has generated the error as abovementioned (i.e., the screenshot).

mesh = meshio.read(os.path.join(os.path.dirname(__file__), os.pardir,'data',"Basehead.obj"))

I changed this code to

mesh=meshio.read( Path('../data/Basehead.obj').resolve())

Then instead of using vertices, faces = viz.get_3d_heads() I used vertices, faces = get_3d_heads()

Changing these lines, I am now able to plot in 2D and 3D.