-
Notifications
You must be signed in to change notification settings - Fork 17
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
base: main
Are you sure you want to change the base?
Add Intan loader #76
Conversation
Intan loader
Co-authored-by: Tolga Dincer <[email protected]>
fix constant from 255 to 256 Co-authored-by: Tolga Dincer <[email protected]>
Co-authored-by: Dimitri Yatsenko <[email protected]>
Co-authored-by: Dimitri Yatsenko <[email protected]>
refactor: 🎨 streamline the code
There was a problem hiding this 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.
Converted to draft to accommodate different Intan file format. |
|
print("") | ||
print( | ||
"Reading Intan Technologies RHS2000 Data File, Version {}.{}".format( | ||
version["major"], version["minor"] | ||
) | ||
) | ||
print("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print("") | |
print( | |
"Reading Intan Technologies RHS2000 Data File, Version {}.{}".format( | |
version["major"], version["minor"] | |
) | |
) | |
print("") |
Can we remove all these print statements?
There was a problem hiding this comment.
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')
"<hh", fid.read(4) | ||
) | ||
|
||
frequency_parameters = {} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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": |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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. |
Co-authored-by: JaerongA <[email protected]>
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 |
There was a problem hiding this comment.
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
GNU GENERAL PUBLIC LICENSE | ||
Version 3, 29 June 2007 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
-
Keep the
rhs_perchannel_loader
module in theelement-interface
repo, but remove therhsutilities
module. -
Make the DataJoint fork of the
load-rhs-notebook-python
repo pip installable. Then we can just import therhsutilities
module inelement-interface
. We will still have the same issue that we have with thescanreader
package, as it is not on PyPI, but let's deal with that at a later time. -
Rename the DataJoint fork of
load-rhs-notebook-python
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@tdincer Which function will we use to read from the single |
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 |
There was a problem hiding this comment.
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.
No description provided.