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

WIP mb/image2pulsetrain #54

Closed
wants to merge 1 commit into from

Conversation

mbeyeler
Copy link
Member

Work in progress: Add functionality to encode an image as a list of pulse trains.

@coveralls
Copy link

coveralls commented Dec 19, 2016

Coverage Status

Coverage decreased (-3.5%) to 82.45% when pulling 7a1cb44 on mbeyeler:mb/image2pulsetrain into 9315dec on uwescience:master.

Copy link
Contributor

@arokem arokem left a comment

Choose a reason for hiding this comment

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

LGTM. Just had a few comments/questions, but nothing is crucial. Would be good to have tests, though.

const_amp=20, const_freq=20, rftype='gaussian', rfsize=None,
tsample=0.005 / 1000, dur=0.5, pulsedur=0.5 / 1000.,
interphasedur=0.5 / 1000., pulsetype='cathodicfirst'):
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe only try to import skimage if a string is provided, or if the image is RGB? We could allow a simple gray-scale input, if people want to provide that directly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree, except we always need it for resizing the image accordingly... (see below)

# Convert image to grayscale
img_large = rgb2gray(np.array(img)).astype(np.float32)

# Maximize contrast
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this lead to confusing results in an experiment in which different contrasts are used?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Added an input argument max_contrast so users can choose.

yhi = np.max(xyr[:, 1] + xyr[:, 2])

# Resize the image accordingly and flip up down
img_resize = resize(img_large, (yhi - ylo, xhi - xlo))
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we'll always need skimage for this...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, unfortunately...

for e in implant:
rf = receptive_field(e, xg, yg, rftype, rfsize)
magn.append(np.mean(rf * img_resize))
magn = np.array(magn)
Copy link
Contributor

Choose a reason for hiding this comment

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

We might be able to preallocate this one.

e_s += "'frequency'."
raise ValueError(e_s)

pt = Psycho2Pulsetrain(tsample, freq=freq, amp=amp, dur=dur,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe there's a way to speed up/save memory by doing these all in the same time-series object? OTOH, might not be worth the hassle.

@mbeyeler mbeyeler closed this Jan 30, 2017
@mbeyeler mbeyeler deleted the mb/image2pulsetrain branch January 30, 2017 22:28
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.

None yet

3 participants