Commit 2aa5e6ae authored by Michiel Cottaar's avatar Michiel Cottaar
Browse files

BUG: fixed application of surface mask

parent 14a1afa0
Pipeline #5230 failed with stage
in 7 minutes and 53 seconds
......@@ -16,11 +16,12 @@ import cifti
basis_func, best_fit_arr = basis.read(args.field)
img = nibabel.load(args.surface)
req = request.read_surface(img, args.mask, nsplit=args.nsplit)
mask = nibabel.load(args.mask).darrays[0].data != 0
surf = CorticalMesh.read(img)[mask]
req = request.read_surface(surf, nsplit=args.nsplit)
field = req.get_evaluator(basis_func)(best_fit_arr)
surf = CorticalMesh.read(img)
density = sp.zeros(field.shape[0])
density = sp.sqrt((field ** 2).sum(-1))
......@@ -33,7 +34,6 @@ for idx in range(arr_triangle.shape[0]):
conn, val = sp.broadcast_arrays(surf.faces, arr_triangle[idx][None, :])
nconn = sp.bincount(conn.flatten(), minlength=surf.nvertices)
arr_vertices[idx] = sp.bincount(conn.flatten(), val.flatten(), minlength=surf.nvertices) / nconn
bm = cifti.BrainModel.from_mask(sp.ones(surf.nvertices, dtype='bool'),
name=img.darrays[0].metadata['AnatomicalStructurePrimary'])
cifti.write(args.dyad, arr_vertices, (cifti.Scalar.from_names(['density (crossing)', 'density (total)', 'radiality', 'x', 'y', 'z']), bm))
bm = cifti.BrainModel.from_mask(mask, name=img.darrays[0].metadata['AnatomicalStructurePrimary'])
cifti.write(args.output, arr_vertices, (cifti.Scalar.from_names(['density (crossing)', 'density (total)', 'radiality', 'x', 'y', 'z']), bm))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment