Skip to content

Commit cea96cb

Browse files
committed
Reproin: make __dups indexes be per series (by default, not tunable ATM)
1 parent 9fb1ae6 commit cea96cb

File tree

3 files changed

+58
-5
lines changed

3 files changed

+58
-5
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ All notable changes to this project will be documented (for humans) in this file
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.5.2] - Date
8+
9+
TODO Summary
10+
11+
### Added
12+
### Changed
13+
14+
- Reproin heuristic: `__dup` indices would now be assigned incrementally
15+
individually per each sequence, so there is a chance to properly treat
16+
associate for multi-file (e.g. `fmap`) sequences
17+
18+
### Deprecated
19+
### Fixed
20+
### Removed
21+
### Security
22+
23+
724
## [0.5.1] - 2018-07-05
825
Bugfix release
926

heudiconv/heuristics/reproin.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,23 @@ def infotodict(seqinfo):
653653
return info
654654

655655

656-
def get_dups_marked(info):
656+
def get_dups_marked(info, per_series=True):
657+
"""
658+
659+
Parameters
660+
----------
661+
info
662+
per_series: bool
663+
If set to False, it would create growing index through all series. That
664+
could lead to non-desired effects if some "multi file" scans (such as
665+
fmap with magnitude{1,2} and phasediff) would not be able to associate
666+
multiple files for the same acquisition. By default (True) dup indices
667+
would be per each series (change introduced in 0.5.2)
668+
669+
Returns
670+
-------
671+
672+
"""
657673
# analyze for "cancelled" runs, if run number was explicitly specified and
658674
# thus we ended up with multiple entries which would mean that older ones
659675
# were "cancelled"
@@ -664,13 +680,20 @@ def get_dups_marked(info):
664680
lgr.warning("Detected %d duplicated run(s) for template %s: %s",
665681
len(series_ids) - 1, template[0], series_ids[:-1])
666682
# copy the duplicate ones into separate ones
683+
if per_series:
684+
dup_id = 0 # reset since declared per series
667685
for dup_series_id in series_ids[:-1]:
668686
dup_id += 1
669687
dup_template = (
670688
'%s__dup-%02d' % (template[0], dup_id),
671689
) + template[1:]
672690
# There must have not been such a beast before!
673-
assert dup_template not in info
691+
if dup_template in info:
692+
raise AssertionError(
693+
"{} is already known to info={}. "
694+
"May be a bug for per_series=True handling?"
695+
"".format(dup_template, info)
696+
)
674697
info[dup_template] = [dup_series_id]
675698
info[template] = series_ids[-1:]
676699
assert len(info[template]) == 1

heudiconv/heuristics/test_reproin.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,25 @@ def test_get_dups_marked():
99
no_dups = {('some',): [1]}
1010
assert get_dups_marked(no_dups) == no_dups
1111

12-
assert get_dups_marked(
13-
OrderedDict([
12+
info = OrderedDict(
13+
[
1414
(('bu', 'du'), [1, 2]),
1515
(('smth',), [3]),
1616
(('smth2',), ['a', 'b', 'c'])
17-
])) == \
17+
]
18+
)
19+
20+
assert get_dups_marked(info) == get_dups_marked(info, True) == \
21+
{
22+
('bu__dup-01', 'du'): [1],
23+
('bu', 'du'): [2],
24+
('smth',): [3],
25+
('smth2__dup-01',): ['a'],
26+
('smth2__dup-02',): ['b'],
27+
('smth2',): ['c']
28+
}
29+
30+
assert get_dups_marked(info, per_series=False) == \
1831
{
1932
('bu__dup-01', 'du'): [1],
2033
('bu', 'du'): [2],

0 commit comments

Comments
 (0)