Skip to content

Commit 45cdf37

Browse files
committed
Remove the removal of original echos when output=input (i.e. never delete original data)
1 parent 0d5f9d8 commit 45cdf37

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

bidscoin/bidsapps/echocombine.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def echocombine(bidsfolder: str, pattern: str, participant: list, output: str, a
2828
:param bidsfolder: The bids-directory with the (multi-echo) subject data
2929
:param pattern: Globlike recursive search pattern (relative to the subject/session folder) to select the first echo of the images that need to be combined, e.g. '*task-*echo-1*'
3030
:param participant: List of sub-# identifiers to be processed (the sub-prefix can be left out). If not specified then all participants will be processed
31-
:param output: Determines where the output is saved. It can be the name of a BIDS datatype folder, such as 'func', or of the derivatives folder, i.e. 'derivatives'. If output = [the name of the input datatype folder] then the original echo images are replaced by one combined image. If output is left empty then the combined image is saved in the input datatype folder and the original echo images are moved to the {unknowndatatype} folder
31+
:param output: Determines where the output is saved. It can be the name of a BIDS datatype folder, such as 'func', or of the derivatives folder, i.e. 'derivatives'. If output is left empty then the combined image is saved in the input datatype folder and the original echo images are moved to the {unknowndatatype} folder
3232
:param algorithm: Combination algorithm, either 'PAID', 'TE' or 'average'
3333
:param weights: Weights for each echo
3434
:param force: Boolean to overwrite existing ME target files
@@ -116,11 +116,6 @@ def echocombine(bidsfolder: str, pattern: str, participant: list, output: str, a
116116
newecho.parent.mkdir(parents=True, exist_ok=True)
117117
echo.replace(newecho)
118118
echo.with_suffix('').with_suffix('.json').replace(newecho.with_suffix('').with_suffix('.json'))
119-
elif output == datatype:
120-
for echo in echos:
121-
LOGGER.info(f"Removing original echo image: {echo}")
122-
echo.unlink()
123-
echo.with_suffix('').with_suffix('.json').unlink()
124119

125120
# Construct the path names relative to the session folder (used for updating the IntendedFor list and scans.tsv file)
126121
oldechos_rel = [echo.relative_to(session).as_posix() for echo in echos]
@@ -130,7 +125,7 @@ def echocombine(bidsfolder: str, pattern: str, participant: list, output: str, a
130125
else:
131126
cefile_rel = cefile.relative_to(session).as_posix()
132127

133-
# Update the IntendedFor fields of the fieldmaps (i.e. remove the old echos, add the echo-combined image and, optionally, the new echos)
128+
# Update the IntendedFor fields of the field maps (i.e. remove the old echos, add the echo-combined image and, optionally, the new echos)
134129
if output != 'derivatives' and (session/'fmap').is_dir():
135130
for fmap in (session/'fmap').glob('*.json'):
136131

bidscoin/cli/_echocombine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescri
2727
parser.add_argument('bidsfolder', help='The bids-directory with the (multi-echo) subject data')
2828
parser.add_argument('pattern', help="Globlike recursive search pattern (relative to the subject/session folder) to select the first echo of the images that need to be combined, e.g. '*task-*echo-1*'")
2929
parser.add_argument('-p','--participant', help='Space separated list of sub-# identifiers to be processed (the sub-prefix can be left out). If not specified then all participants will be processed', nargs='+', metavar='LABEL')
30-
parser.add_argument('-o','--output', help=f"A string that determines where the output is saved. It can be the name of a BIDS datatype folder, such as 'func', or of the derivatives folder, i.e. 'derivatives'. If output = [the name of the input datatype folder] then the original echo images are replaced by one combined image. If output is left empty then the combined image is saved in the input datatype folder and the original echo images are moved to the 'extra_data' folder", default='', metavar='DESTINATION')
30+
parser.add_argument('-o','--output', help=f"A string that determines where the output is saved. It can be the name of a BIDS datatype folder, such as 'func', or of the derivatives folder, i.e. 'derivatives'. If output is left empty then the combined image is saved in the input datatype folder and the original echo images are moved to the 'extra_data' folder", default='', metavar='DESTINATION')
3131
parser.add_argument('-a','--algorithm', help='Combination algorithm', choices=['PAID', 'TE', 'average'], default='TE')
3232
parser.add_argument('-w','--weights', help='Weights for each echo', nargs='*', default=None, type=float, metavar='WEIGHT')
3333
parser.add_argument('-f','--force', help='Process all images, regardless whether target images already exist. Otherwise the echo-combination will be skipped', action='store_true')

0 commit comments

Comments
 (0)