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 the option to choose alignment channel by name #222

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ashlar/filepattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ def tile_rc(self, i):
row = i // self.width + self.row_offset
col = i % self.width + self.col_offset
return row, col

def get_from_channel_map(self, c):
if isinstance(c, int):
return self.channel_map[c]
if c in list(self.channel_map.values()):
return c
raise Exception(f"{c} was notrecognized as a channel")


class FilePatternReader(reg.Reader):
Expand All @@ -119,5 +126,5 @@ def read(self, series, c):

def filename(self, series, c):
row, col = self.metadata.tile_rc(series)
c = self.metadata.channel_map[c]
c = self.metadata.get_from_channel_map(c)
return self.pattern.format(row=row, col=col, channel=c)
9 changes: 8 additions & 1 deletion ashlar/fileseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,17 @@ def tile_rc(self, i):
if self.layout == "snake" and col % 2 == 1:
row = self.height - 1 - row
return row, col

def get_from_channel_map(self, c):
if isinstance(c, int):
return self.channel_map[c]
if c in list(self.channel_map.values()):
return c
raise Exception(f"{c} was notrecognized as a channel")

def filename(self, series, c):
well, series = self.all_series[self.active_series[series]]
c = self.channel_map[c]
c = self.get_from_channel_map(c)
components = self.filename_components[well, series, c]
return self.pattern.format(**components)

Expand Down
5 changes: 3 additions & 2 deletions ashlar/scripts/ashlar.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ def main(argv=sys.argv):
" exist."),
)
parser.add_argument(
'-c', '--align-channel', dest='align_channel', type=int,
'-c', '--align-channel', dest='align_channel',
default='0', metavar='CHANNEL',
help=('Reference channel number for image alignment. Numbering starts'
' at 0.'),
' at 0. If fileseries or filepattern is used, it may be channel'
' name.'),
)
parser.add_argument(
'--flip-x', default=False, action='store_true',
Expand Down