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

Brezovec conversion #2

Open
h-mayorquin opened this issue Jul 13, 2023 · 5 comments
Open

Brezovec conversion #2

h-mayorquin opened this issue Jul 13, 2023 · 5 comments
Assignees

Comments

@h-mayorquin
Copy link
Collaborator

This is to organize the conversion. Some general resources.

Fictrac:
https://github.com/rjdmoore/fictrac/tree/master

The paper:
https://www.biorxiv.org/content/10.1101/2022.03.20.485047v1

I will update as more information comes

@h-mayorquin
Copy link
Collaborator Author

h-mayorquin commented Jul 13, 2023

To-do:

@h-mayorquin
Copy link
Collaborator Author

h-mayorquin commented Sep 21, 2023

Code to extract the datetime of fictract @alessandratrapani:

from pathlib import Path
from datetime import datetime
from zoneinfo import ZoneInfo

folder_path = Path("/home/heberto/Clandinin-CN-data-share/brezovec_example_data/fictrac")
file_path = folder_path / "fictrac-20200620_122048.dat"
assert file_path.is_file(), f"File path {file_path} does not exist."

def read_first_timestamp_from_file(file_path):
    with open(file_path, 'r') as file:
        # Read the first data line
        first_line = file.readline()
        
        # Split by comma and extract the timestamp (the 22nd column)
        timestamp = float(first_line.split(',')[21]) / 1000.0  # Transform to seconds
        
    return timestamp

def convert_to_los_angeles_time(utc_timestamp):
    # Convert the timestamp to a UTC datetime object
    utc_time = datetime.utcfromtimestamp(utc_timestamp).replace(tzinfo=ZoneInfo("UTC"))

    # Convert the UTC time to Los Angeles local time
    los_angeles_tz = ZoneInfo('America/Los_Angeles')
    los_angeles_time = utc_time.astimezone(los_angeles_tz)

    return los_angeles_time

timestamp = read_first_timestamp_from_file(file_path)
la_time = convert_to_los_angeles_time(timestamp)
print(la_time)

We should have similar functions to extract the session_start_time from the xml in bruker.

Once we have all the starting times we should follow the proceedure here to set those times right:
https://neuroconv.readthedocs.io/en/main/user_guide/temporal_alignment.html#temporal-alignment-within-nwbconverter

@alessandratrapani
Copy link
Contributor

Once we have all the starting times we should follow the proceedure here to set those times right:
https://neuroconv.readthedocs.io/en/main/user_guide/temporal_alignment.html#temporal-alignment-within-nwbconverter

We need additional information before proceeding with this, correct? For instance, the VoltageRecording_00x.csv file, that should contain the TTL signals for synchronization.

@h-mayorquin
Copy link
Collaborator Author

That would be better, but we can improve on what we have right now by using the information that we already have available. Specially critical is to adjust the starting_time of the anatomy so it is after the functional one. That is, the start time of the functional anatomy should be around 30 minutes from the session_start_time.

@h-mayorquin
Copy link
Collaborator Author

Linking here for provenance:
catalystneuro/neuroconv#598

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

No branches or pull requests

2 participants