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

Support multiple codewords for the same target #1646

Merged
merged 1 commit into from
Nov 13, 2019

Conversation

ttung
Copy link
Collaborator

@ttung ttung commented Nov 9, 2019

to_json walks through each of the targets/r/c in a codebook when trying to save. Unfortunately, selecting an array with the same target twice results in a 3D array (target/r/c) rather than a 2D array (r/c).

This PR rewrites to_json so it can handle multiple codewords that decode to the same target. Rather than selecting by label, we walk through each of the targets by integer offset. This also optimizes the walkthrough of the codebook object by finding all the non-zero points in numpy code rather than in python code. With the seqFISH dataset, this is at least a 10x speedup in writing out the json file. With denser codebooks, the speedup probably is inconsequential.

Test plan: wrote a test that has multiple codewords for the same target. it crashes without the fix and succeehds with the fix.
Fixes: #1643

@ttung ttung requested a review from shanaxel42 November 9, 2019 03:28
@codecov-io
Copy link

codecov-io commented Nov 9, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@3072f3c). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1646   +/-   ##
=========================================
  Coverage          ?   89.87%           
=========================================
  Files             ?      220           
  Lines             ?     8145           
  Branches          ?        0           
=========================================
  Hits              ?     7320           
  Misses            ?      825           
  Partials          ?        0
Impacted Files Coverage Δ
starfish/core/codebook/test/test_to_json.py 100% <100%> (ø)
starfish/core/codebook/codebook.py 96.85% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3072f3c...ffbf5d5. Read the comment docs.

Copy link
Collaborator

@shanaxel42 shanaxel42 left a comment

Choose a reason for hiding this comment

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

nice!

@ttung ttung force-pushed the tonytung-codebook-to-json-test branch from f5218ec to eaf77da Compare November 13, 2019 06:38
@ttung ttung force-pushed the tonytung-multiple-words-for-target branch from 00d4993 to 5c0839e Compare November 13, 2019 06:39
`to_json` walks through each of the targets/r/c in a codebook when trying to save.  Unfortunately, selecting an array with the same target twice results in a 3D array (target/r/c) rather than a 2D array (r/c).

This PR rewrites to_json so it can handle multiple codewords that decode to the same target.  Rather than selecting by label, we walk through each of the targets by integer offset.  This also optimizes the walkthrough of the codebook object by finding all the non-zero points in numpy code rather than in python code.  With the seqFISH dataset, this is at least a 10x speedup in writing out the json file.  With denser codebooks, the speedup probably is inconsequential.

Test plan: wrote a test that has multiple codewords for the same target.  it crashes without the fix and succeehds with the fix.
Fixes: #1643
@ttung ttung force-pushed the tonytung-multiple-words-for-target branch from 5c0839e to ffbf5d5 Compare November 13, 2019 06:51
@ttung ttung changed the base branch from tonytung-codebook-to-json-test to master November 13, 2019 06:51
@ttung ttung merged commit 7892e0a into master Nov 13, 2019
@ttung ttung deleted the tonytung-multiple-words-for-target branch November 13, 2019 16:04
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.

format_seqFISH using starfish 0.1.8
3 participants