psychoinformatics-de / remodnav

Robust Eye Movement Detection for Natural Viewing
Other
59 stars 16 forks source link

How do I use remodnav in jupyter book or colab? #44

Closed AlfredLTennyson closed 1 year ago

AlfredLTennyson commented 1 year ago

I have been trying to use remodnav in colab and jupyterbook. The documentation of the remodnav says to use command line call specifying the location of the input file and output file. But it gives me an error ,saying "invalid syntax". I am not able to figure out what is wrong. Can you please tell me what i should do? Thankyou.

Following is the code- remodnav "C:\Users\ansha\Downloads\T_Trial1.tsv" \ "C:\Users\ansha\Downloads\rT_Trial1.tsv" 1.0 1000.0

and following is the error: Input In [3] remodnav "C:\Users\ansha\Downloads\T_Trial1.tsv" \ ^ SyntaxError: invalid syntax

AlfredLTennyson commented 1 year ago

I am using jupyterbook in anaconda.

adswa commented 1 year ago

Could it be that you're running a command line call in a python cell?

AlfredLTennyson commented 1 year ago

yes,i am exactly doing that. i assumed that was command line is. i am still a novice in python. can you please tell me what i should do? i will be really grateful.

adswa commented 1 year ago

No worries at all. Remodnav is a Python package (i.e., software written in Python). However, Python packages can not only be used in Python sessions or scripts, but they can also have entrypoints that define their command line API (i.e., commands like "remodnav" that you run, for example, in a Linux terminal, Windows CMD, or Mac terminal). Thus, you can either use the command line commands in a code cell that can execute command line calls, or you can import the necessary Python functions and run them in a normal Python code cell.

Both will be possible in a notebook. command line call I am not a user of Google collab, but as far as I know there are two ways to run command line calls. One is by using a bash kernel instead of a python kernel. This might very well not be possible, because it is a question of installation, which I assume you don't control. The easier one is by prefixing each line with an exclamation mark (i..e, !remodnav <infile> <outfile> .... If that doesn't work right away, try to google for something like "running bash commands in collab notebook" for collab specific content and documentation on that.

Python API The python API isn't really documented because the command line bundles all relevant functions up, but you can check out https://github.com/psychoinformatics-de/remodnav/blob/master/remodnav/__init__.py (which calls all the right functions in the right order) or https://github.com/psychoinformatics-de/remodnav/issues/38#issuecomment-1066904327 for an additional example . You would need to load inputs and save outputs yourself, and do the imports of other Python packages / requirements (such as numpy,...).

Hope that helps!

adswa commented 1 year ago

I'm going to close this issue as "answered", but if you have further questions or problems, please reopen it or create a new one. :) All the best!

AlfredLTennyson commented 1 year ago

Thanks a ton and apologies for the late response. I used %%shell in colab and i think it did work. %%shell remodnav "T_Trial1.tsv" \ "remo_out" 1.0 1000.0 But, now i am getting a weird error . Traceback (most recent call last): File "/usr/local/bin/remodnav", line 8, in <module> sys.exit(main()) File "/usr/local/lib/python3.7/dist-packages/remodnav/__init__.py", line 148, in main 'min_blink_duration', 'dilate_nan', 'median_filter_length', File "/usr/local/lib/python3.7/dist-packages/remodnav/clf.py", line 855, in preproc data['x'][mask] = np.nan ValueError: cannot convert float NaN to integer

Though I did look at the previous query of the same sort,but i am not able to implement it as my gaze data is already in degrees.

AlfredLTennyson commented 1 year ago

https://github.com/AlfredLTennyson/eye_gaze_data_for_1_trial/blob/main/T_Trial1.tsv

here is the data file. Thanks a ton in advance.