Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change output filename & ScreenResolution return values #34

Merged
merged 15 commits into from
Nov 7, 2023
Merged

Conversation

julia-pfarr
Copy link
Member

  • output filenames: according to issue output_dir + filename #24: output file has now the prefix of the edf file. If edf file already contains "_eyetrack" suffix, it is not written again.
  • ScreenResolution threw an error because it expected integers but it returned strings --> changed to integers

- output filenames: according to issue #24: output file has now the prefix of the edf file. If edf file already contains "_eyetrack" suffix, it is not written again.
- ScreenResolution threw an error because it expected integers but it returned strings --> changed to integers
@julia-pfarr julia-pfarr mentioned this pull request Oct 25, 2023
@julia-pfarr
Copy link
Member Author

Included code to extract eyetrack.tsv from samples_asc

@Remi-Gau like I already said in the BIDS chat group, the tests are failing and and the output_dir is not considered when I run eye2bids in the terminal (i.e., I define --output_dir but my output is saved in my input_file directory anyway). I don't know why this is, apparently I changed something that caused this. But I don't think I can find out what it is

@Remi-Gau
Copy link
Contributor

side note: tests were already failing in #33 so I will probably start fixing things in main and then get back to this PR.

@julia-pfarr
Copy link
Member Author

side note: tests were already failing in #33 so I will probably start fixing things in main and then get back to this PR.

Yes but that was due to a different thing which I fixed with this PR (it was ScreeResolution expected int and got str, which I fixed in this PR. Now it's a different error)

Comment on lines -8 to -19
SampleCoordinateUnits: !!str
SampleCoordinateSystem: !!str
EnvironmentCoordinates: !!str
ScreenDistance: !!int
ScreenRefreshRate: !!int
ScreenSize: [!!float]
SampleCoordinateUnits: str
SampleCoordinateSystem: str
EnvironmentCoordinates: str
ScreenDistance: int
ScreenRefreshRate: int
ScreenSize: [float]

# Recommended (leave empty if not available but put information you want to share with your dataset here!):
SoftwareVersion: !!str
ScreenAOIDefinition: [!!str [!!int]]
SoftwareVersion: str
ScreenAOIDefinition: [str, [int]]
EyeCameraSettings:
EyeTrackerDistance: !!float
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was breaking the parsing of the yml file

Comment on lines 429 to 436
if substring_eyetrack not in filename:
with open(output_dir / (filename + "_eyetrack.tsv"), "w") as outfile:
eyetrack_tsv.to_csv(outfile, sep="\t", index=False, compression="gzip")
e2b_log.info(f"file generated: {output_dir / (filename + '_eyetrack.tsv')}")
else:
with open(output_dir / (filename + ".tsv"), "w") as outfile:
eyetrack_tsv.to_csv(outfile, sep="\t", index=False, compression="gzip")
e2b_log.info(f"file generated: {output_dir / (filename + '.tsv')}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO refactor

Comment on lines 417 to 424
if substring_events not in filename:
with open(output_dir / (filename + "_events.json"), "w") as outfile:
json.dump(events_json, outfile, indent=4)
e2b_log.info(f"file generated: {output_dir / (filename + '_events.json')}")
else:
with open(output_dir / (filename + ".json"), "w") as outfile:
json.dump(events_json, outfile, indent=4)
e2b_log.info(f"file generated: {output_dir / (filename + '.json')}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO refactor

# to json
# file naming check

filename = Path(input_file).stem
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed this line to make sure that the file would be created in the correct folder

@@ -7,7 +7,7 @@

from eye2bids.edf2bids import (
_check_edf2asc_present,
_convert_edf_to_asc,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests were failing because you had not renamed this function here and it could not be imported

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AHA!!!! Thanks for explaining!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well more precisely the test could not even start running because of that

now I am running them and figuring out why se get some failures

Comment on lines 429 to 436
if substring_eyetrack not in filename:
with open(output_dir / (filename + "_eyetrack.tsv"), "w") as outfile:
eyetrack_tsv.to_csv(outfile, sep="\t", index=False, compression="gzip")
e2b_log.info(f"file generated: {output_dir / (filename + '_eyetrack.tsv')}")
else:
with open(output_dir / (filename + ".tsv"), "w") as outfile:
eyetrack_tsv.to_csv(outfile, sep="\t", index=False, compression="gzip")
e2b_log.info(f"file generated: {output_dir / (filename + '.tsv')}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we may have those different cases of filenaming

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mszinte had a dataset where he already had named the files with "_eyetrack" at the end. I don't know if this is super common but I guess it could be that others had the same idea of naming their files like this without knowing BIDS. Then when they want to convert it to BIDS they would get "_eyetrack_eyetrack" as output filename

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK fair, I will refactor the code a bit for this rare case

pytest.skip("edf2asc missing")

input_dir = eyelink_test_data_dir / "decisions"
input_dir = eyelink_test_data_dir / "satf"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one EDF file in the "decision" dataset that fails.
Need to figure out why: maybe not in this PR though

@Remi-Gau
Copy link
Contributor

Remi-Gau commented Nov 7, 2023

@julia-pfarr Can you check that the data is saved in the appropriate folder?

@Remi-Gau Remi-Gau merged commit aa55681 into main Nov 7, 2023
6 checks passed
@julia-pfarr
Copy link
Member Author

@julia-pfarr Can you check that the data is saved in the appropriate folder?

yes, data is saved in the appropriate folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants