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

Add Intan loader #76

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open

Add Intan loader #76

wants to merge 34 commits into from

Conversation

tdincer
Copy link
Contributor

@tdincer tdincer commented Feb 13, 2023

No description provided.

@tdincer tdincer changed the title Ad Intan loader Add Intan loader Feb 13, 2023
Copy link
Collaborator

@JaerongA JaerongA left a comment

Choose a reason for hiding this comment

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

Thanks @tdincer. Just one comment.

element_interface/intan_loader.py Outdated Show resolved Hide resolved
@kabilar kabilar self-assigned this Feb 13, 2023
@kabilar kabilar marked this pull request as draft February 13, 2023 21:04
@kabilar
Copy link
Collaborator

kabilar commented Feb 13, 2023

Converted to draft to accommodate different Intan file format.

@tdincer tdincer requested a review from kabilar February 14, 2023 22:52
@tdincer
Copy link
Contributor Author

tdincer commented Feb 14, 2023

rhs_perchannel_loader.py is the one developed to read per channel data. The rest of the files are taken from https://github.com/datajoint/load-rhs-notebook-python. Note that there is a COPYING file, which is the original license from the same repo.

@tdincer tdincer marked this pull request as ready for review February 14, 2023 23:12
Comment on lines 65 to 71
print("")
print(
"Reading Intan Technologies RHS2000 Data File, Version {}.{}".format(
version["major"], version["minor"]
)
)
print("")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
print("")
print(
"Reading Intan Technologies RHS2000 Data File, Version {}.{}".format(
version["major"], version["minor"]
)
)
print("")

Can we remove all these print statements?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest migrating all element print statements to datajoint-python-formatted logging

import logging
logger = logging.getLogger('datajoint')
logger.info('existing statement')

JaerongA
JaerongA previously approved these changes Feb 15, 2023
"<hh", fid.read(4)
)

frequency_parameters = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

I find this hard to read, and I would expect it would be tough for newcomers to audit/maintain as a result. I'd suggest adopting the kinds of formatting adjustments I proposed in #74

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the best reason not to make such edits would be if we anticipated further developments from the original intan team. If the original repo is stable and unlikely to update, I would prioritize readability over exactness in the copy

# Define function print_all_channel_names
def print_all_channel_names(result):

# Print all amplifier_channels
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be a for loop?

ax.set_title(channel_name)
ax.set_xlabel("Time (s)")

if signal_type == "amplifier_channels":
Copy link
Contributor

@CBroz1 CBroz1 Feb 15, 2023

Choose a reason for hiding this comment

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

This looks to me like it could be a dict

signal_type_lookup = dict(
  amplifier_channels = ["Voltage", "amplifier_data"]
  dc_amplifier_channels = ...
)
ylabel, signal_data_name = signal_type_lookup.get(signal_type, [None, None])
if not ylabel:
  raise ValueError("Err message")

for count, this_channel in enumerate(signal_group):
if this_channel["custom_channel_name"] == channel_name:
return True, count
return False, 0
Copy link
Contributor

Choose a reason for hiding this comment

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

By reserving -1 as your not-found value, you could have this function only return the this_channel value and not need to juggle two returns

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not my code.

@tdincer
Copy link
Contributor Author

tdincer commented Feb 15, 2023

Please do not spend time on correcting the rhsutilities.py. It's not our code.

If Intan updates the code, any changes made in this file will make the comparison of this file and the original file harder.

result["amp_settle_data"] = data["amp_settle_data"]
result["board_dig_in_data"] = data["board_dig_in_data"]
result["board_dig_out_data"] = data["board_dig_out_data"]
result["header"] = header
Copy link
Collaborator

Choose a reason for hiding this comment

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

added this to output the header

Comment on lines 1 to 2
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might get confusing to mix licenses within a single repo. Let's brainstorm on alternative options.

Copy link
Contributor Author

@tdincer tdincer Feb 16, 2023

Choose a reason for hiding this comment

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

I'm also concerned about that. Alternatively, we can make the entire module a separate package. But then we would need to add some lines to the COPYING. In that case, we can fork from the intan's original repo.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the idea of forking Intan's repo and making modifications there. That would allow us to pull from the base repository as it is updated, and to contribute back to the base repository if we have fixes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can move the new code in this PR to https://github.com/datajoint/load-rhs-notebook-python. We will need to change the repos' name, though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Perfect. How about the following:

  1. Keep the rhs_perchannel_loader module in the element-interface repo, but remove the rhsutilities module.

  2. Make the DataJoint fork of the load-rhs-notebook-python repo pip installable. Then we can just import the rhsutilities module in element-interface. We will still have the same issue that we have with the scanreader package, as it is not on PyPI, but let's deal with that at a later time.

  3. Rename the DataJoint fork of load-rhs-notebook-python.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Let's try to finish it today.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kabilar I applied all three changes you suggested.

@kabilar
Copy link
Collaborator

kabilar commented Feb 17, 2023

@tdincer Which function will we use to read from the single *.rhs file which contains the metadata and raw data from all channels?

@tdincer
Copy link
Contributor Author

tdincer commented Feb 17, 2023

@tdincer Which function will we use to read from the single *.rhs file which contains the metadata and raw data from all channels?

We will use the one in the intanrhsreader as follows:

from intanrhsreader import load_file

rhsdata = load_file('filename.rhs')


elif signal_type == "board":
signal = np.memmap(file_path, dtype=np.uint16)
signal = (signal - 32768) * 0.0003125 # Convert to volts
Copy link
Member

Choose a reason for hiding this comment

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

fudge factors. Please turn into named constants.

@kabilar kabilar removed their assignment Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

Successfully merging this pull request may close these issues.

5 participants