bids-standard / eye2bids

Convert eyetracking data to a BIDS compatible format (BEP20)
MIT License
5 stars 6 forks source link

eye2bids in datalad run #43

Closed julia-pfarr closed 10 months ago

julia-pfarr commented 10 months ago

I exectued datalad run like this:

datalad run -m "convert edf to bids" \ 
  --input "sourcedata/sub-01/beh/sub-01_taskname.edf" \
  --output "sourcedata/sub-01/beh/sub-01_taskname_events.asc" \
  --output "sourcedata/sub-01/beh/sub-01_taskname_samples.asc" \
  --output "raw/sub-01/beh/sub-01_taskname_events.json" \
  --output "raw/sub-01/beh/sub-01_taskname_eyetrack.json" \
  --output "raw/sub-01/beh/sub-01_taskname_eyetrack.tsv" \
  "eye2bids --input_file sourcedata/sub-01/beh/sub-01_taskname.edf --metadata_file raw/manual_metadata_taskname.yml --output_dir raw/sub-01/beh/ {inputs} {outputs}"

--> specifying the asc files as "input" in datalad run throws an error "file not found" --> not specifying the asc files as output doesn't help, it does the same as the code pasted above

julia-pfarr commented 10 months ago

@Remi-Gau I think we could try this:

# Get the target of a symlink
Path('symlink.txt').resolve()

in _def_check_inputsas cheked_input_file = Path(input_file).resolve() ?

Remi-Gau commented 10 months ago

For me it's even worse: I cannot even convert to asc...

I run:

datalad run -m "convert edf to bids" \
  --input "2eyes/sub-99_task-FreeView_run-01_eyeData.edf" \
  "eye2bids --input_file 2eyes/sub-99_task-FreeView_run-01_eyeData.edf --output_dir asc"

Datalad dataset is the simplest possible:

└── 2eyes
    └── sub-99_task-FreeView_run-01_eyeData.edf -> ../.git/annex/objects/Zp/p3/MD5E-s1149202--340b1b3407866f190a9fe22fb895b162.edf/MD5E-s1149202--340b1b3407866f190a9fe22fb895b162.edf

This is the error I get:

Error: expand to show

[INFO   ] Making sure inputs are available (this may take some time) 
[INFO   ] == Command start (output follows) ===== 

EDF2ASC: EyeLink EDF file -> ASCII (text) file translator
EDF2ASC version 4.2.762.0 Linux   standalone Jul 20 2023 
(c)1995-2023 by SR Research, last modified Jul 20 2023

USAGE: edf2asc  [options] 
OPTIONS: -p  writes output with same name to  directory
         -p *. writes output of same name with new extension
         -d  creates log data file
         -t use only tabs as delimiters
         -c check consistency
         -z disable check consistency and fix the errors
                   -v verbose - reports warning messages. 
                   -y overwrite asc file if exists.
If no output file name, will match wildcards on input file name,
and will write output files to new path or will overwrite old files.
DATA OPTIONS: -sp  outputs sample raw pupil position if present
              -sh  outputs sample HREF angle data if present
              -sg  outputs sample GAZE data if present (default)
      -l or -nr   outputs left-eye data only if binocular data file
      -r or -nl   outputs right-eye data only if binocular data file
      -res         outputs resolution data if present
      -vel (-fvel) outputs sample velocity (-fvel matches EDFVIEW numbers)
      -s or -ne   outputs sample data only
      -e or -ns   outputs event data only
      -miss      replaces missing (x,y) in samples with 
      -setres   uses a fixed , resolution always
      -defres   uses a default , resolution if none in file
      -nv         hide viewer commands
      -nst        blocks output of start events
      -nmsg       blocks message event output
      -neye       outputs only non-eye events (for sample-only files)
 Use  -neye     to get samples labeled with non-eye events only
 Use  -neye -ns to get non-eye events only
 Use  -utf8/-UTF8 to force the output file to be opened using utf-8 encoding form.
-nflags to disable flags data for EyeLink II or EyeLink1000 data files.
-hpos  output head marker positions
-avg  output average data 
-ftime output float time 
-input output input values in samples.
-buttons output buttons values in samples.
-failsafe runs in failsafe mode and recover partial edf file 
-ntarget to disable target data for EyeLink1000 Remote data files.
-ntime_check to disable large time stamp check.
-npa_check disable pupil area check to get gaze, href and raw data. 
-logmsg load eb_message.log to integrate with edf file. 
[10:53:36] INFO     input file found:                                                                                          edf2bids.py:39
                    /home/remi/github/eye2bids/tmp/et/.git/annex/objects/Zp/p3/MD5E-s1149202--340b1b3407866f190a9fe22fb895b162               
                    .edf/MD5E-s1149202--340b1b3407866f190a9fe22fb895b162.edf                                                                 

EDF2ASC: EyeLink EDF file -> ASCII (text) file translator
EDF2ASC version 4.2.762.0 Linux   standalone Jul 20 2023 
(c)1995-2023 by SR Research, last modified Jul 20 2023

processing file /home/remi/github/eye2bids/tmp/et/.git/annex/objects/Zp/p3/MD5E-s1149202--340b1b3407866f190a9fe22fb895b162.edf/MD5E-s1149202--340b1b3407866f190a9fe22fb895b162.edf 
loadEvents = 1
Could not open output file /home/remi/github/eye2bids/tmp/et/.git/annex/objects/Zp/p3/MD5E-s1149202--340b1b3407866f190a9fe22fb895b162.edf/MD5E-s1149202--340b1b3407866f190a9fe22fb895b162_events.asc 
Traceback (most recent call last):
  File "/home/remi/miniconda3/bin/eye2bids", line 8, in 
    sys.exit(cli())
             ^^^^^
  File "/home/remi/github/eye2bids/eye2bids/_cli.py", line 53, in cli
    edf2bids(
  File "/home/remi/github/eye2bids/eye2bids/edf2bids.py", line 353, in edf2bids
    events = _load_asc_file(events_asc_file)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/remi/github/eye2bids/eye2bids/edf2bids.py", line 291, in _load_asc_file
    with open(events_asc_file) as f:
         ^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/remi/github/eye2bids/tmp/et/.git/annex/objects/Zp/p3/MD5E-s1149202--340b1b3407866f190a9fe22fb895b162.edf/MD5E-s1149202--340b1b3407866f190a9fe22fb895b162_events.asc'
[INFO   ] == Command exit (modification check follows) ===== 
[INFO   ] The command had a non-zero exit code. If this is expected, you can save the changes with 'datalad save -d . -r -F .git/COMMIT_EDITMSG' 
run(error): /home/remi/github/eye2bids/tmp/et (dataset) [eye2bids --input_file 2eyes/sub-99_task-...]

Seems EDF2ASC tries to write to the annex...

Remi-Gau commented 10 months ago

I get the same error when not using datalad run

julia-pfarr commented 10 months ago

I get the same error when not using datalad run

You mean when running the code on a symlink file but not within datalad run? Because same.

When I ran edf2asc outside our converter it worked fine for me. It wrote the asc file and took the actual filename

Remi-Gau commented 10 months ago

OK I think I fixed it and you were correct the .resolve() was the issue using .absolute() fixed it.

Will push a PR so you can test it.