Skip to content

Commit

Permalink
Merge remote-tracking branch 'github/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jdtournier committed Nov 10, 2022
2 parents 5ae3320 + 8b787e5 commit 0b41219
Show file tree
Hide file tree
Showing 32 changed files with 474 additions and 274 deletions.
2 changes: 1 addition & 1 deletion bin/population_template
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ def execute(): #pylint: disable=unused-variable
if use_masks:
progress = app.ProgressBar('Reslicing input masks to average header', len(ins))
for inp in ins:
run.command('mrtransform ' + inp.ims_path[cid] + ' ' + inp.msk_transformed + ' ' +
run.command('mrtransform ' + inp.msk_path + ' ' + inp.msk_transformed + ' ' +
'-interp nearest -template ' + cns.templates[0] + ' ' +
datatype_option)
progress.increment()
Expand Down
78 changes: 37 additions & 41 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,13 @@ targets = []


todo, headers, object_deps, file_flags = {}, {}, {}, {}
formatstr=''
lock = threading.Lock()
print_lock = threading.Lock()
index_lock = threading.Lock()
stop = False
error_stream = None
main_cindex = 0
todo_index = 0

logfile = open ('build.log', 'wb') #pylint: disable=consider-using-with
timingfile = None
Expand Down Expand Up @@ -687,6 +689,14 @@ for filepath in list_unexpected_bin_files(exe_suffix):
class TargetException (Exception):
pass


def next_index ():
global todo_index
with index_lock:
todo_index+=1
return todo_index


class Entry:
def __init__ (self, name):
name = os.path.normpath (name)
Expand Down Expand Up @@ -725,7 +735,8 @@ class Entry:



def execute (self, cindex, formatstr):
def execute (self):
global formatstr
folder = os.path.dirname (self.name)
try:
os.makedirs (folder)
Expand All @@ -742,7 +753,7 @@ class Entry:
fd.write ('<file>' + entry + '</file>\n')
fd.write ('</qresource>\n</RCC>\n')
if self.cmd:
return execute (formatstr.format (cindex, self.action, self.name), self.cmd)
return execute (formatstr.format (next_index(), self.action, self.name), self.cmd)
return None


Expand Down Expand Up @@ -1079,25 +1090,21 @@ def list_lib_deps ():


def build_next ():
global stop, main_cindex
total_count = len(todo)
cindex = 0
formatstr = '({:>'+str(len(str(total_count)))+'}/'+str(total_count)+') [{}] {}'
global stop, formatstr
formatstr = '({:>'+str(len(str(initial_num_todo)))+'}/'+str(initial_num_todo)+') [{}] {}'

try:
while not stop:
current = None
with lock:
if todo:
for label, item in todo.items():
if item.currently_being_processed:
for name,entry in todo.items():
if entry.currently_being_processed:
continue
unsatisfied_deps = set(item.deps).intersection (todo.keys())
unsatisfied_deps = set(entry.deps).intersection (todo.keys())
if not unsatisfied_deps:
item.currently_being_processed = True
current = label
main_cindex+=1
cindex = main_cindex
entry.currently_being_processed = True
current = name
break
else:
stop = max (stop, 1)
Expand All @@ -1109,15 +1116,16 @@ def build_next ():
continue

target = todo[current]
if target.execute(cindex, formatstr):
if target.execute():
target.currently_being_processed = False
stop = 2
return

with lock:
del todo[current]

except Exception:
except Exception as excp:
disp (str(excp))
stop = 2
return

Expand Down Expand Up @@ -1408,19 +1416,8 @@ except TargetException as excp: # pylint: disable=unused-variable

# for nogui config, remove GUI elements from targets and todo list:
if nogui:
nogui_targets = []
for entry in targets:
if not is_GUI_target (entry):
nogui_targets.append (entry)
targets = nogui_targets

nogui_todo = {}
for label, item in todo.items():
if not is_GUI_target (item.name):
nogui_todo[label] = item
todo = nogui_todo


targets = [ entry for entry in targets if not is_GUI_target (entry) ]
todo = { name:entry for name, entry in todo.items() if not is_GUI_target (name) }



Expand All @@ -1444,11 +1441,9 @@ Printing dependencies for all files:
entry.display()
sys.exit (0)

todo_tmp = {}
for label, item in todo.items():
if item.action != '--' and item.need_rebuild():
todo_tmp[label] = item
todo = todo_tmp

# remove todo items that don't need rebuild:
todo = { name:entry for name, entry in todo.items() if entry.action != '--' and entry.need_rebuild() }

log ('TODO list contains ' + str(len(todo)) + ''' items
Expand All @@ -1464,18 +1459,19 @@ except (KeyError, ValueError):
num_processors = os.sysconf('SC_NPROCESSORS_ONLN')
except ValueError:
num_processors = 1
log ('''
while todo:
Build will use ''' + str(num_processors) + ''' threads
stop = False
main_cindex = 0
num_todo_previous = len(todo)
''')

log ('''

launching ''' + str(num_processors) + ''' threads
while todo:

''')
stop = False
num_todo_previous = len(todo)
initial_num_todo = len(todo)
todo_index = 0

threads = []
for i in range (1, num_processors): # pylint: disable=unused-variable
Expand Down
12 changes: 6 additions & 6 deletions cmd/connectomestats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void run()
++progress;
}
}
const bool nans_in_data = data.allFinite();
const bool nans_in_data = !data.allFinite();

// Only add contrast matrix row number to image outputs if there's more than one hypothesis
auto postfix = [&] (const size_t i) { return (num_hypotheses > 1) ? ("_" + hypotheses[i].name()) : ""; };
Expand All @@ -293,24 +293,24 @@ void run()
}
for (size_t i = 0; i != num_hypotheses; ++i) {
if (!hypotheses[i].is_F()) {
save_matrix (mat2vec.V2M (abs_effect_size.col(i)), "abs_effect" + postfix(i) + ".csv");
save_matrix (mat2vec.V2M (abs_effect_size.col(i)), output_prefix + "abs_effect" + postfix(i) + ".csv");
++progress;
if (num_vgs == 1)
save_matrix (mat2vec.V2M (std_effect_size.col(i)), "std_effect" + postfix(i) + ".csv");
save_matrix (mat2vec.V2M (std_effect_size.col(i)), output_prefix + "std_effect" + postfix(i) + ".csv");
} else {
++progress;
}
++progress;
}
if (nans_in_data || extra_columns.size()) {
save_matrix (mat2vec.V2M (cond), "cond.csv");
save_matrix (mat2vec.V2M (cond), output_prefix + "cond.csv");
++progress;
}
if (num_vgs == 1) {
save_matrix (mat2vec.V2M (stdev.row(0)), "std_dev.csv");
save_matrix (mat2vec.V2M (stdev.row(0)), output_prefix + "std_dev.csv");
} else {
for (size_t i = 0; i != num_vgs; ++i) {
save_matrix (mat2vec.V2M (stdev.row(i)), "std_dev" + str(i) + ".csv");
save_matrix (mat2vec.V2M (stdev.row(i)), output_prefix + "std_dev" + str(i) + ".csv");
++progress;
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/mrclusterstats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void run() {
write_output (stdev.row(0), *v2v, prefix + "std_dev.mif", output_header);
} else {
for (size_t i = 0; i != num_vgs; ++i) {
write_output (stdev.row(i), *v2v, prefix + "std_dev.mif", output_header);
write_output (stdev.row(i), *v2v, prefix + "std_dev" + str(i) + ".mif", output_header);
++progress;
}
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/mrtransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ void run ()
if (modulate_jac)
apply_linear_jacobian (output, linear_transform);

DWI::export_grad_commandline (output);

} else if (warp.valid()) {

if (replace)
Expand Down
Loading

0 comments on commit 0b41219

Please sign in to comment.