Search is not available for this dataset
text
stringlengths
75
104k
def stop(self): """ Stop the primitive manager. """ for p in self.primitives[:]: p.stop() StoppableLoopThread.stop(self)
def load_scene(self, scene_path, start=False): """ Loads a scene on the V-REP server. :param str scene_path: path to a V-REP scene file :param bool start: whether to directly start the simulation after loading the scene .. note:: It is assumed that the scene file is always available on...
def get_motor_position(self, motor_name): """ Gets the motor current position. """ return self.call_remote_api('simxGetJointPosition', self.get_object_handle(motor_name), streaming=True)
def set_motor_position(self, motor_name, position): """ Sets the motor target position. """ self.call_remote_api('simxSetJointTargetPosition', self.get_object_handle(motor_name), position, sending=True)
def get_motor_force(self, motor_name): """ Retrieves the force or torque applied to a joint along/about its active axis. """ return self.call_remote_api('simxGetJointForce', self.get_object_handle(motor_name), streaming=True)
def set_motor_force(self, motor_name, force): """ Sets the maximum force or torque that a joint can exert. """ self.call_remote_api('simxSetJointForce', self.get_object_handle(motor_name), force, sending=True)
def get_object_position(self, object_name, relative_to_object=None): """ Gets the object position. """ h = self.get_object_handle(object_name) relative_handle = (-1 if relative_to_object is None else self.get_object_handle(relative_to_object)) return self.call...
def set_object_position(self, object_name, position=[0, 0, 0]): """ Sets the object position. """ h = self.get_object_handle(object_name) return self.call_remote_api('simxSetObjectPosition', h, -1, position, sending=True)
def get_object_handle(self, obj): """ Gets the vrep object handle. """ if obj not in self._object_handles: self._object_handles[obj] = self._get_object_handle(obj=obj) return self._object_handles[obj]
def get_collision_state(self, collision_name): """ Gets the collision state. """ return self.call_remote_api('simxReadCollision', self.get_collision_handle(collision_name), streaming=True)
def get_collision_handle(self, collision): """ Gets a vrep collisions handle. """ if collision not in self._object_handles: h = self._get_collision_handle(collision) self._object_handles[collision] = h return self._object_handles[collision]
def add_cube(self, name, position, sizes, mass): """ Add Cube """ self._create_pure_shape(0, 239, sizes, mass, [0, 0]) self.set_object_position("Cuboid", position) self.change_object_name("Cuboid", name)
def add_cylinder(self, name, position, sizes, mass, precision=[10, 10]): """ Add Cylinder """ self._create_pure_shape(2, 239, sizes, mass, precision) self.set_object_position("Cylinder", position) self.change_object_name("Cylinder", name)
def change_object_name(self, old_name, new_name): """ Change object name """ h = self._get_object_handle(old_name) if old_name in self._object_handles: self._object_handles.pop(old_name) lua_code = "simSetObjectName({}, '{}')".format(h, new_name) self._inject_lua_code...
def _create_pure_shape(self, primitive_type, options, sizes, mass, precision): """ Create Pure Shape """ lua_code = "simCreatePureShape({}, {}, {{{}, {}, {}}}, {}, {{{}, {}}})".format( primitive_type, options, sizes[0], sizes[1], sizes[2], mass, precision[0], precision[1]) self._inje...
def _inject_lua_code(self, lua_code): """ Sends raw lua code and evaluate it wihtout any checking! """ msg = (ctypes.c_ubyte * len(lua_code)).from_buffer_copy(lua_code.encode()) self.call_remote_api('simxWriteStringStream', 'my_lua_code', msg)
def call_remote_api(self, func_name, *args, **kwargs): """ Calls any remote API func in a thread_safe way. :param str func_name: name of the remote API func to call :param args: args to pass to the remote API call :param kwargs: args to pass to the remote API call .. note:: You...
def run(self, **kwargs): """ Start the tornado server, run forever""" try: loop = IOLoop() app = self.make_app() app.listen(self.port) loop.start() except socket.error as serr: # Re raise the socket error if not "[Errno 98] Address al...
def run(self): """ Run an infinite REQ/REP loop. """ while True: req = self.socket.recv_json() try: answer = self.handle_request(req) self.socket.send(json.dumps(answer)) except (AttributeError, TypeError) as e: self.s...
def open(self, port, baudrate=1000000, timeout=0.05): """ Opens a new serial communication (closes the previous communication if needed). :raises: :py:exc:`~pypot.dynamixel.io.DxlError` if the port is already used. """ self._open(port, baudrate, timeout) logger.info("Op...
def close(self, _force_lock=False): """ Closes the serial communication if opened. """ if not self.closed: with self.__force_lock(_force_lock) or self._serial_lock: self._serial.close() self.__used_ports.remove(self.port) logger.info("Closing port...
def flush(self, _force_lock=False): """ Flushes the serial communication (both input and output). """ if self.closed: raise DxlError('attempt to flush a closed serial communication') with self.__force_lock(_force_lock) or self._serial_lock: self._serial.flushInput() ...
def ping(self, id): """ Pings the motor with the specified id. .. note:: The motor id should always be included in [0, 253]. 254 is used for broadcast. """ pp = self._protocol.DxlPingPacket(id) try: self._send_packet(pp, error_handler=None) retu...
def scan(self, ids=range(254)): """ Pings all ids within the specified list, by default it finds all the motors connected to the bus. """ return [id for id in ids if self.ping(id)]
def get_model(self, ids): """ Gets the model for the specified motors. """ to_get_ids = [i for i in ids if i not in self._known_models] models = [dxl_to_model(m) for m in self._get_model(to_get_ids, convert=False)] self._known_models.update(zip(to_get_ids, models)) return tuple(...
def change_id(self, new_id_for_id): """ Changes the id of the specified motors (each id must be unique on the bus). """ if len(set(new_id_for_id.values())) < len(new_id_for_id): raise ValueError('each id must be unique.') for new_id in new_id_for_id.itervalues(): if self...
def change_baudrate(self, baudrate_for_ids): """ Changes the baudrate of the specified motors. """ self._change_baudrate(baudrate_for_ids) for motor_id in baudrate_for_ids: if motor_id in self._known_models: del self._known_models[motor_id] if motor_id in...
def get_status_return_level(self, ids, **kwargs): """ Gets the status level for the specified motors. """ convert = kwargs['convert'] if 'convert' in kwargs else self._convert srl = [] for id in ids: try: srl.extend(self._get_status_return_level((id, ), ...
def set_status_return_level(self, srl_for_id, **kwargs): """ Sets status return level to the specified motors. """ convert = kwargs['convert'] if 'convert' in kwargs else self._convert if convert: srl_for_id = dict(zip(srl_for_id.keys(), [('never', '...
def switch_led_on(self, ids): """ Switches on the LED of the motors with the specified ids. """ self._set_LED(dict(zip(ids, itertools.repeat(True))))
def switch_led_off(self, ids): """ Switches off the LED of the motors with the specified ids. """ self._set_LED(dict(zip(ids, itertools.repeat(False))))
def enable_torque(self, ids): """ Enables torque of the motors with the specified ids. """ self._set_torque_enable(dict(zip(ids, itertools.repeat(True))))
def disable_torque(self, ids): """ Disables torque of the motors with the specified ids. """ self._set_torque_enable(dict(zip(ids, itertools.repeat(False))))
def get_pid_gain(self, ids, **kwargs): """ Gets the pid gain for the specified motors. """ return tuple([tuple(reversed(t)) for t in self._get_pid_gain(ids, **kwargs)])
def set_pid_gain(self, pid_for_id, **kwargs): """ Sets the pid gain to the specified motors. """ pid_for_id = dict(itertools.izip(pid_for_id.iterkeys(), [tuple(reversed(t)) for t in pid_for_id.values()])) self._set_pid_gain(pid_for_id, **kwargs)
def get_control_table(self, ids, **kwargs): """ Gets the full control table for the specified motors. ..note:: This function requires the model for each motor to be known. Querring this additional information might add some extra delay. """ error_handler = kwargs['error_handler...
def nearest_keys(self, key): """Find the nearest_keys (l2 distance) thanks to a cKDTree query""" if not isinstance(key, tuple): _key = (key,) if self.__stale: self.generate_tree() d, idx = self.__tree.query( _key, self.k_neighbors, distance_upper_bound...
def interpolate_motor_positions(self, input_key, nearest_keys): """ Process linear interpolation to estimate actual speed and position of motors Method specific to the :meth:~pypot.primitive.move.Move.position() structure it is a KDTreeDict[timestamp] = {dict[motor]=(position,speed)} ...
def flushed_print(*args, **kwargs): """ Use to replace print(*args, flush=True) that doesn't exist for python<3.3 """ print(*args, **kwargs) file = kwargs.get('file', sys.stdout) file.flush() if file is not None else sys.stdout.flush()
def from_config(config, strict=True, sync=True, use_dummy_io=False, **extra): """ Returns a :class:`~pypot.robot.robot.Robot` instance created from a configuration dictionnary. :param dict config: robot configuration dictionary :param bool strict: make sure that all ports, motors are availaible. ...
def check_motor_eprom_configuration(config, dxl_io, motor_names): """ Change the angles limits depanding on the robot configuration ; Check if the return delay time is set to 0. """ changed_angle_limits = {} changed_return_delay_time = {} for name in motor_names: m = config['motors'...
def from_json(json_file, sync=True, strict=True, use_dummy_io=False, **extra): """ Returns a :class:`~pypot.robot.robot.Robot` instance created from a JSON configuration file. For details on how to write such a configuration file, you should refer to the section :ref:`config_file`. """ with open(json_...
def stop_move_recorder(self, move_name): """Allow more easily than stop_primitive() to save in a filename the recorded move""" recorder = getattr(self.robot, '_{}_recorder'.format(move_name)) recorder.stop() with open('{}.record'.format(move_name), 'w') as f: recorder.move.sa...
def start_move_player(self, move_name, speed=1.0, backwards=False): """Move player need to have a move file <move_name.record> in the working directory to play it""" # check if running try: player = getattr(self.robot, '_{}_player'.format(move_name)) if player.ru...
def _get_gdcmconv(): """ Get the full path to gdcmconv. If not found raise error """ gdcmconv_executable = settings.gdcmconv_path if gdcmconv_executable is None: gdcmconv_executable = _which('gdcmconv') if gdcmconv_executable is None: gdcmconv_executable = _which('gdcmconv.ex...
def compress_directory(dicom_directory): """ This function can be used to convert a folder of jpeg compressed images to an uncompressed ones :param dicom_directory: directory of dicom files to compress """ if _is_compressed(dicom_directory): return logger.info('Compressing dicom files ...
def is_dicom_file(filename): """ Util function to check if file is a dicom file the first 128 bytes are preamble the next 4 bytes should contain DICM otherwise it is not a dicom :param filename: file to check for the DICM header block :type filename: six.string_types :returns: True if it is...
def _is_compressed(dicom_file, force=False): """ Check if dicoms are compressed or not """ header = pydicom.read_file(dicom_file, defer_size="1 KB", stop_before_pixels=True, force=force) uncompressed_types ...
def _decompress_dicom(dicom_file, output_file): """ This function can be used to convert a jpeg compressed image to an uncompressed one for further conversion :param input_file: single dicom file to decompress """ gdcmconv_executable = _get_gdcmconv() subprocess.check_output([gdcmconv_executab...
def dicom_diff(file1, file2): """ Shows the fields that differ between two DICOM images. Inspired by https://code.google.com/p/pydicom/source/browse/source/dicom/examples/DicomDiff.py """ datasets = compressed_dicom.read_file(file1), compressed_dicom.read_file(file2) rep = [] for dataset in ...
def get_slice(self, slice_type, slice_number, time_point=0): """ Returns a slice of the dataset. slice.data contains the window/levelled values, in uint8 slice.original_data contains the original data for this slice :param time_point: in case of 4d nifti the 4th d...
def _get_number_of_slices(self, slice_type): """ Get the number of slices in a certain direction """ if slice_type == SliceType.AXIAL: return self.dimensions[self.axial_orientation.normal_component] elif slice_type == SliceType.SAGITTAL: return self.dimens...
def dicom_series_to_nifti(original_dicom_directory, output_file=None, reorient_nifti=True): """ Converts dicom single series (see pydicom) to nifty, mimicking SPM Examples: See unit test will return a dictionary containing - the NIFTI under key 'NIFTI' - the NIFTI file path under 'NII_FILE' -...
def dicom_array_to_nifti(dicom_list, output_file, reorient_nifti=True): """ Converts dicom single series (see pydicom) to nifty, mimicking SPM Examples: See unit test will return a dictionary containing - the NIFTI under key 'NIFTI' - the NIFTI file path under 'NII_FILE' - the BVAL file path ...
def are_imaging_dicoms(dicom_input): """ This function will check the dicom headers to see which type of series it is Possibilities are fMRI, DTI, Anatomical (if no clear type is found anatomical is used) :param dicom_input: directory with dicom files or a list of dicom objects """ # if it is ...
def _get_vendor(dicom_input): """ This function will check the dicom headers to see which type of series it is Possibilities are fMRI, DTI, Anatomical (if no clear type is found anatomical is used) """ # check if it is siemens if common.is_siemens(dicom_input): logger.info('Found manufac...
def _get_first_header(dicom_directory): """ Function to get the first dicom file form a directory and return the header Useful to determine the type of data to convert :param dicom_directory: directory with dicom files """ # looping over all files for root, _, file_names in os.walk(dicom_di...
def _shrink_file(dicom_file_in, subsample_factor): """ Anonimize a single dicomfile :param dicom_file_in: filepath for input file :param dicom_file_out: filepath for output file :param fields_to_keep: dicom tags to keep """ # Default meta_fields # Required fields according to reference ...
def reorient_image(input_image, output_image): """ Change the orientation of the Image data in order to be in LAS space x will represent the coronal plane, y the sagittal and z the axial plane. x increases from Right (R) to Left (L), y from Posterior (P) to Anterior (A) and z from Inferior (I) to Superi...
def _reorient_3d(image): """ Reorganize the data for a 3d nifti """ # Create empty array where x,y,z correspond to LR (sagittal), PA (coronal), IS (axial) directions and the size # of the array in each direction is the same with the corresponding direction of the input image. new_image = numpy.z...
def dicom_to_nifti(dicom_input, output_file=None): """ This is the main dicom to nifti conversion fuction for philips images. As input philips images are required. It will then determine the type of images and do the correct conversion Examples: See unit test :param output_file: file path to the o...
def _assert_explicit_vr(dicom_input): """ Assert that explicit vr is used """ if settings.validate_multiframe_implicit: header = dicom_input[0] if header.file_meta[0x0002, 0x0010].value == '1.2.840.10008.1.2': raise ConversionError('IMPLICIT_VR_ENHANCED_DICOM')
def _is_multiframe_diffusion_imaging(dicom_input): """ Use this function to detect if a dicom series is a philips multiframe dti dataset NOTE: We already assue this is a 4D dataset as input """ header = dicom_input[0] if "PerFrameFunctionalGroupsSequence" not in header: return False ...
def _is_multiframe_4d(dicom_input): """ Use this function to detect if a dicom series is a philips multiframe 4D dataset """ # check if it is multi frame dicom if not common.is_multiframe_dicom(dicom_input): return False header = dicom_input[0] # check if there are multiple stacks ...
def _is_singleframe_4d(dicom_input): """ Use this function to detect if a dicom series is a philips singleframe 4D dataset """ header = dicom_input[0] # check if there are stack information slice_number_mr_tag = Tag(0x2001, 0x100a) if slice_number_mr_tag not in header: return False ...
def _is_bval_type_a(grouped_dicoms): """ Check if the bvals are stored in the first of 2 currently known ways for single frame dti """ bval_tag = Tag(0x2001, 0x1003) bvec_x_tag = Tag(0x2005, 0x10b0) bvec_y_tag = Tag(0x2005, 0x10b1) bvec_z_tag = Tag(0x2005, 0x10b2) for group in grouped_di...
def _is_bval_type_b(grouped_dicoms): """ Check if the bvals are stored in the second of 2 currently known ways for single frame dti """ bval_tag = Tag(0x0018, 0x9087) bvec_tag = Tag(0x0018, 0x9089) for group in grouped_dicoms: if bvec_tag in group[0] and bval_tag in group[0]: ...
def _multiframe_to_nifti(dicom_input, output_file): """ This function will convert philips 4D or anatomical multiframe series to a nifti """ # Read the multiframe dicom file logger.info('Read dicom file') multiframe_dicom = dicom_input[0] # Create mosaic block logger.info('Creating dat...
def _singleframe_to_nifti(grouped_dicoms, output_file): """ This function will convert a philips singleframe series to a nifti """ # Create mosaic block logger.info('Creating data block') full_block = _singleframe_to_block(grouped_dicoms) logger.info('Creating affine') # Create the nif...
def _singleframe_to_block(grouped_dicoms): """ Generate a full datablock containing all timepoints """ # For each slice / mosaic create a data volume block data_blocks = [] for index in range(0, len(grouped_dicoms)): logger.info('Creating block %s of %s' % (index + 1, len(grouped_dicoms)...
def _get_grouped_dicoms(dicom_input): """ Search all dicoms in the dicom directory, sort and validate them fast_read = True will only read the headers not the data """ # if all dicoms have an instance number try sorting by instance number else by position if [d for d in dicom_input if 'Instance...
def _create_affine_multiframe(multiframe_dicom): """ Function to create the affine matrix for a siemens mosaic dataset This will work for siemens dti and 4D if in mosaic format """ first_frame = multiframe_dicom[Tag(0x5200, 0x9230)][0] last_frame = multiframe_dicom[Tag(0x5200, 0x9230)][-1] #...
def _multiframe_to_block(multiframe_dicom): """ Generate a full datablock containing all stacks """ # Calculate the amount of stacks and slices in the stack number_of_stack_slices = int(common.get_ss_value(multiframe_dicom[Tag(0x2001, 0x105f)][0][Tag(0x2001, 0x102d)])) number_of_stacks = int(int...
def _create_bvals_bvecs(multiframe_dicom, bval_file, bvec_file, nifti, nifti_file): """ Write the bvals from the sorted dicom files to a bval file Inspired by https://github.com/IBIC/ibicUtils/blob/master/ibicBvalsBvecs.py """ # create the empty arrays number_of_stack_slices = common.get_ss_val...
def _fix_diffusion_images(bvals, bvecs, nifti, nifti_file): """ This function will remove the last timepoint from the nifti, bvals and bvecs if the last vector is 0,0,0 This is sometimes added at the end by philips """ # if all zero continue of if the last bvec is not all zero continue if numpy....
def _create_singleframe_bvals_bvecs(grouped_dicoms, bval_file, bvec_file, nifti, nifti_file): """ Write the bvals from the sorted dicom files to a bval file """ # create the empty arrays bvals = numpy.zeros([len(grouped_dicoms)], dtype=numpy.int32) bvecs = numpy.zeros([len(grouped_dicoms), 3]) ...
def dicom_to_nifti(dicom_input, output_file): """ This function will convert an anatomical dicom series to a nifti Examples: See unit test :param output_file: filepath to the output nifti :param dicom_input: directory with the dicom files for a single scan, or list of read in dicoms """ if...
def _remove_duplicate_slices(dicoms): """ Search dicoms for localizers and delete them """ # Loop overall files and build dict dicoms_dict = {} filtered_dicoms = [] for dicom_ in dicoms: if tuple(dicom_.ImagePositionPatient) not in dicoms_dict: dicoms_dict[tuple(dicom_.I...
def _remove_localizers_by_imagetype(dicoms): """ Search dicoms for localizers and delete them """ # Loop overall files and build dict filtered_dicoms = [] for dicom_ in dicoms: if 'ImageType' in dicom_ and 'LOCALIZER' in dicom_.ImageType: continue # 'Projection Image'...
def _remove_localizers_by_orientation(dicoms): """ Removing localizers based on the orientation. This is needed as in some cases with ct data there are some localizer/projection type images that cannot be distiguished by the dicom headers. This is why we kick out all orientations that do not have more t...
def _convert_slice_incement_inconsistencies(dicom_input): """ If there is slice increment inconsistency detected, for the moment CT images, then split the volumes into subvolumes based on the slice increment and process each volume separately using a space constructed based on the highest resolution increment ...
def read_dicom_directory(dicom_directory, stop_before_pixels=False): """ Read all dicom files in a given directory (stop before pixels) :type stop_before_pixels: bool :type dicom_directory: six.string_types :param stop_before_pixels: Should we stop reading before the pixeldata (handy if we only wan...
def is_hitachi(dicom_input): """ Use this function to detect if a dicom series is a hitachi dataset :param dicom_input: directory with dicom files for 1 scan of a dicom_header """ # read dicom header header = dicom_input[0] if 'Manufacturer' not in header or 'Modality' not in header: ...
def is_ge(dicom_input): """ Use this function to detect if a dicom series is a GE dataset :param dicom_input: list with dicom objects """ # read dicom header header = dicom_input[0] if 'Manufacturer' not in header or 'Modality' not in header: return False # we try generic conversi...
def is_philips(dicom_input): """ Use this function to detect if a dicom series is a philips dataset :param dicom_input: directory with dicom files for 1 scan of a dicom_header """ # read dicom header header = dicom_input[0] if 'Manufacturer' not in header or 'Modality' not in header: ...
def is_siemens(dicom_input): """ Use this function to detect if a dicom series is a siemens dataset :param dicom_input: directory with dicom files for 1 scan """ # read dicom header header = dicom_input[0] # check if manufacturer is Siemens if 'Manufacturer' not in header or 'Modality'...
def is_multiframe_dicom(dicom_input): """ Use this function to detect if a dicom series is a siemens 4D dataset NOTE: Only the first slice will be checked so you can only provide an already sorted dicom directory (containing one series) :param dicom_input: directory with dicom files for 1 scan ...
def is_valid_imaging_dicom(dicom_header): """ Function will do some basic checks to see if this is a valid imaging dicom """ # if it is philips and multiframe dicom then we assume it is ok try: if is_philips([dicom_header]): if is_multiframe_dicom([dicom_header]): ...
def get_volume_pixeldata(sorted_slices): """ the slice and intercept calculation can cause the slices to have different dtypes we should get the correct dtype that can cover all of them :type sorted_slices: list of slices :param sorted_slices: sliced sored in the correct order to create volume ...
def _get_slice_pixeldata(dicom_slice): """ the slice and intercept calculation can cause the slices to have different dtypes we should get the correct dtype that can cover all of them :type dicom_slice: pydicom object :param dicom_slice: slice to get the pixeldata for """ data = dicom_slice...
def get_numpy_type(dicom_header): """ Make NumPy format code, e.g. "uint16", "int32" etc from two pieces of info: mosaic.PixelRepresentation -- 0 for unsigned, 1 for signed; mosaic.BitsAllocated -- 8, 16, or 32 :param dicom_header: the read dicom file/headers :returns: numpy format string ...
def get_fd_array_value(tag, count): """ Getters for data that also work with implicit transfersyntax :param count: number of items in the array :param tag: the tag to read """ if tag.VR == 'OB' or tag.VR == 'UN': values = [] for i in range(count): start = i * 8 ...
def get_fd_value(tag): """ Getters for data that also work with implicit transfersyntax :param tag: the tag to read """ if tag.VR == 'OB' or tag.VR == 'UN': value = struct.unpack('d', tag.value)[0] return value return tag.value
def set_fd_value(tag, value): """ Setters for data that also work with implicit transfersyntax :param value: the value to set on the tag :param tag: the tag to read """ if tag.VR == 'OB' or tag.VR == 'UN': value = struct.pack('d', value) tag.value = value
def get_fl_value(tag): """ Getters for data that also work with implicit transfersyntax :param tag: the tag to read """ if tag.VR == 'OB' or tag.VR == 'UN': value = struct.unpack('f', tag.value)[0] return value return tag.value
def get_is_value(tag): """ Getters for data that also work with implicit transfersyntax :param tag: the tag to read """ # data is int formatted as string so convert te string first and cast to int if tag.VR == 'OB' or tag.VR == 'UN': value = int(tag.value.decode("ascii").replace(" ", ""...
def get_ss_value(tag): """ Getters for data that also work with implicit transfersyntax :param tag: the tag to read """ # data is int formatted as string so convert te string first and cast to int if tag.VR == 'OB' or tag.VR == 'UN': value = struct.unpack('h', tag.value)[0] retu...
def set_ss_value(tag, value): """ Setter for data that also work with implicit transfersyntax :param value: the value to set on the tag :param tag: the tag to read """ if tag.VR == 'OB' or tag.VR == 'UN': value = struct.pack('h', value) tag.value = value
def apply_scaling(data, dicom_headers): """ Rescale the data based on the RescaleSlope and RescaleOffset Based on the scaling from pydicomseries :param dicom_headers: dicom headers to use to retreive the scaling factors :param data: the input data """ # Apply the rescaling if needed pr...
def write_bvec_file(bvecs, bvec_file): """ Write an array of bvecs to a bvec file :param bvecs: array with the vectors :param bvec_file: filepath to write to """ if bvec_file is None: return logger.info('Saving BVEC file: %s' % bvec_file) with open(bvec_file, 'w') as text_file: ...