repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
lacava/few
few/variation.py
VariationMixin.mutate
def mutate(self,p_i,func_set,term_set): #, max_depth=2 """point mutation, addition, removal""" self.point_mutate(p_i,func_set,term_set)
python
def mutate(self,p_i,func_set,term_set): #, max_depth=2 """point mutation, addition, removal""" self.point_mutate(p_i,func_set,term_set)
[ "def", "mutate", "(", "self", ",", "p_i", ",", "func_set", ",", "term_set", ")", ":", "#, max_depth=2", "self", ".", "point_mutate", "(", "p_i", ",", "func_set", ",", "term_set", ")" ]
point mutation, addition, removal
[ "point", "mutation", "addition", "removal" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/variation.py#L174-L176
lacava/few
few/variation.py
VariationMixin.point_mutate
def point_mutate(self,p_i,func_set,term_set): """point mutation on individual p_i""" # point mutation x = self.random_state.randint(len(p_i)) arity = p_i[x].arity[p_i[x].in_type] # find eligible replacements based on arity and type reps = [n for n in func_set+term_set ...
python
def point_mutate(self,p_i,func_set,term_set): """point mutation on individual p_i""" # point mutation x = self.random_state.randint(len(p_i)) arity = p_i[x].arity[p_i[x].in_type] # find eligible replacements based on arity and type reps = [n for n in func_set+term_set ...
[ "def", "point_mutate", "(", "self", ",", "p_i", ",", "func_set", ",", "term_set", ")", ":", "# point mutation", "x", "=", "self", ".", "random_state", ".", "randint", "(", "len", "(", "p_i", ")", ")", "arity", "=", "p_i", "[", "x", "]", ".", "arity",...
point mutation on individual p_i
[ "point", "mutation", "on", "individual", "p_i" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/variation.py#L178-L194
lacava/few
few/variation.py
VariationMixin.is_valid_program
def is_valid_program(self,p): """checks whether program p makes a syntactically valid tree. checks that the accumulated program length is always greater than the accumulated arities, indicating that the appropriate number of arguments is alway present for functions. It then checks that ...
python
def is_valid_program(self,p): """checks whether program p makes a syntactically valid tree. checks that the accumulated program length is always greater than the accumulated arities, indicating that the appropriate number of arguments is alway present for functions. It then checks that ...
[ "def", "is_valid_program", "(", "self", ",", "p", ")", ":", "# print(\"p:\",p)", "arities", "=", "list", "(", "a", ".", "arity", "[", "a", ".", "in_type", "]", "for", "a", "in", "p", ")", "accu_arities", "=", "list", "(", "accumulate", "(", "arities", ...
checks whether program p makes a syntactically valid tree. checks that the accumulated program length is always greater than the accumulated arities, indicating that the appropriate number of arguments is alway present for functions. It then checks that the sum of arties +1 exactly equa...
[ "checks", "whether", "program", "p", "makes", "a", "syntactically", "valid", "tree", "." ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/variation.py#L206-L223
lacava/few
few/population.py
run_MDR
def run_MDR(n,stack_float,labels=None): """run utility function for MDR nodes.""" # need to check that tmp is categorical x1 = stack_float.pop() x2 = stack_float.pop() # check data is categorical if len(np.unique(x1))<=3 and len(np.unique(x2))<=3: tmp = np.vstack((x1,x2)).transpose() ...
python
def run_MDR(n,stack_float,labels=None): """run utility function for MDR nodes.""" # need to check that tmp is categorical x1 = stack_float.pop() x2 = stack_float.pop() # check data is categorical if len(np.unique(x1))<=3 and len(np.unique(x2))<=3: tmp = np.vstack((x1,x2)).transpose() ...
[ "def", "run_MDR", "(", "n", ",", "stack_float", ",", "labels", "=", "None", ")", ":", "# need to check that tmp is categorical", "x1", "=", "stack_float", ".", "pop", "(", ")", "x2", "=", "stack_float", ".", "pop", "(", ")", "# check data is categorical", "if"...
run utility function for MDR nodes.
[ "run", "utility", "function", "for", "MDR", "nodes", "." ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/population.py#L49-L66
lacava/few
few/population.py
PopMixin.stack_2_eqn
def stack_2_eqn(self,p): """returns equation string for program stack""" stack_eqn = [] if p: # if stack is not empty for n in p.stack: self.eval_eqn(n,stack_eqn) return stack_eqn[-1] return []
python
def stack_2_eqn(self,p): """returns equation string for program stack""" stack_eqn = [] if p: # if stack is not empty for n in p.stack: self.eval_eqn(n,stack_eqn) return stack_eqn[-1] return []
[ "def", "stack_2_eqn", "(", "self", ",", "p", ")", ":", "stack_eqn", "=", "[", "]", "if", "p", ":", "# if stack is not empty", "for", "n", "in", "p", ".", "stack", ":", "self", ".", "eval_eqn", "(", "n", ",", "stack_eqn", ")", "return", "stack_eqn", "...
returns equation string for program stack
[ "returns", "equation", "string", "for", "program", "stack" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/population.py#L190-L197
lacava/few
few/population.py
PopMixin.stacks_2_eqns
def stacks_2_eqns(self,stacks): """returns equation strings from stacks""" if stacks: return list(map(lambda p: self.stack_2_eqn(p), stacks)) else: return []
python
def stacks_2_eqns(self,stacks): """returns equation strings from stacks""" if stacks: return list(map(lambda p: self.stack_2_eqn(p), stacks)) else: return []
[ "def", "stacks_2_eqns", "(", "self", ",", "stacks", ")", ":", "if", "stacks", ":", "return", "list", "(", "map", "(", "lambda", "p", ":", "self", ".", "stack_2_eqn", "(", "p", ")", ",", "stacks", ")", ")", "else", ":", "return", "[", "]" ]
returns equation strings from stacks
[ "returns", "equation", "strings", "from", "stacks" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/population.py#L199-L204
lacava/few
few/population.py
PopMixin.make_program
def make_program(self,stack,func_set,term_set,max_d,ntype): """makes a program stack""" # print("stack:",stack,"max d:",max_d) if max_d == 0: ts = [t for t in term_set if t.out_type==ntype] if not ts: raise ValueError('no ts. ntype:'+ntype+'. term_set out...
python
def make_program(self,stack,func_set,term_set,max_d,ntype): """makes a program stack""" # print("stack:",stack,"max d:",max_d) if max_d == 0: ts = [t for t in term_set if t.out_type==ntype] if not ts: raise ValueError('no ts. ntype:'+ntype+'. term_set out...
[ "def", "make_program", "(", "self", ",", "stack", ",", "func_set", ",", "term_set", ",", "max_d", ",", "ntype", ")", ":", "# print(\"stack:\",stack,\"max d:\",max_d)", "if", "max_d", "==", "0", ":", "ts", "=", "[", "t", "for", "t", "in", "term_set", "if", ...
makes a program stack
[ "makes", "a", "program", "stack" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/population.py#L207-L229
lacava/few
few/population.py
PopMixin.init_pop
def init_pop(self): """initializes population of features as GP stacks.""" pop = Pop(self.population_size) seed_with_raw_features = False # make programs if self.seed_with_ml: # initial population is the components of the default ml model if (self.ml_type ...
python
def init_pop(self): """initializes population of features as GP stacks.""" pop = Pop(self.population_size) seed_with_raw_features = False # make programs if self.seed_with_ml: # initial population is the components of the default ml model if (self.ml_type ...
[ "def", "init_pop", "(", "self", ")", ":", "pop", "=", "Pop", "(", "self", ".", "population_size", ")", "seed_with_raw_features", "=", "False", "# make programs", "if", "self", ".", "seed_with_ml", ":", "# initial population is the components of the default ml model", ...
initializes population of features as GP stacks.
[ "initializes", "population", "of", "features", "as", "GP", "stacks", "." ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/population.py#L231-L298
lacava/few
few/few.py
main
def main(): """Main function that is called when FEW is run on the command line""" parser = argparse.ArgumentParser(description='A feature engineering wrapper' ' for machine learning algorithms.', add_help=False) parser.add_argument(...
python
def main(): """Main function that is called when FEW is run on the command line""" parser = argparse.ArgumentParser(description='A feature engineering wrapper' ' for machine learning algorithms.', add_help=False) parser.add_argument(...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'A feature engineering wrapper'", "' for machine learning algorithms.'", ",", "add_help", "=", "False", ")", "parser", ".", "add_argument", "(", "'INPUT_FILE'", ...
Main function that is called when FEW is run on the command line
[ "Main", "function", "that", "is", "called", "when", "FEW", "is", "run", "on", "the", "command", "line" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/few.py#L714-L937
lacava/few
few/few.py
FEW.fit
def fit(self, features, labels): """Fit model to data""" # setup data # imputation if self.clean: features = self.impute_data(features) # save the number of features self.n_features = features.shape[1] self.n_samples = features.shape[0] # set ...
python
def fit(self, features, labels): """Fit model to data""" # setup data # imputation if self.clean: features = self.impute_data(features) # save the number of features self.n_features = features.shape[1] self.n_samples = features.shape[0] # set ...
[ "def", "fit", "(", "self", ",", "features", ",", "labels", ")", ":", "# setup data", "# imputation", "if", "self", ".", "clean", ":", "features", "=", "self", ".", "impute_data", "(", "features", ")", "# save the number of features", "self", ".", "n_features",...
Fit model to data
[ "Fit", "model", "to", "data" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/few.py#L172-L417
lacava/few
few/few.py
FEW.transform
def transform(self,x,inds=None,labels = None): """return a transformation of x using population outputs""" if inds: # return np.asarray(Parallel(n_jobs=10)(delayed(self.out)(I,x,labels,self.otype) # for I in inds)).transpose() return np.asar...
python
def transform(self,x,inds=None,labels = None): """return a transformation of x using population outputs""" if inds: # return np.asarray(Parallel(n_jobs=10)(delayed(self.out)(I,x,labels,self.otype) # for I in inds)).transpose() return np.asar...
[ "def", "transform", "(", "self", ",", "x", ",", "inds", "=", "None", ",", "labels", "=", "None", ")", ":", "if", "inds", ":", "# return np.asarray(Parallel(n_jobs=10)(delayed(self.out)(I,x,labels,self.otype) ", "# for I in inds)).transpose()", "ret...
return a transformation of x using population outputs
[ "return", "a", "transformation", "of", "x", "using", "population", "outputs" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/few.py#L419-L432
lacava/few
few/few.py
FEW.impute_data
def impute_data(self,x): """Imputes data set containing Nan values""" imp = Imputer(missing_values='NaN', strategy='mean', axis=0) return imp.fit_transform(x)
python
def impute_data(self,x): """Imputes data set containing Nan values""" imp = Imputer(missing_values='NaN', strategy='mean', axis=0) return imp.fit_transform(x)
[ "def", "impute_data", "(", "self", ",", "x", ")", ":", "imp", "=", "Imputer", "(", "missing_values", "=", "'NaN'", ",", "strategy", "=", "'mean'", ",", "axis", "=", "0", ")", "return", "imp", ".", "fit_transform", "(", "x", ")" ]
Imputes data set containing Nan values
[ "Imputes", "data", "set", "containing", "Nan", "values" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/few.py#L434-L437
lacava/few
few/few.py
FEW.clean
def clean(self,x): """remove nan and inf rows from x""" return x[~np.any(np.isnan(x) | np.isinf(x),axis=1)]
python
def clean(self,x): """remove nan and inf rows from x""" return x[~np.any(np.isnan(x) | np.isinf(x),axis=1)]
[ "def", "clean", "(", "self", ",", "x", ")", ":", "return", "x", "[", "~", "np", ".", "any", "(", "np", ".", "isnan", "(", "x", ")", "|", "np", ".", "isinf", "(", "x", ")", ",", "axis", "=", "1", ")", "]" ]
remove nan and inf rows from x
[ "remove", "nan", "and", "inf", "rows", "from", "x" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/few.py#L439-L441
lacava/few
few/few.py
FEW.clean_with_zeros
def clean_with_zeros(self,x): """ set nan and inf rows from x to zero""" x[~np.any(np.isnan(x) | np.isinf(x),axis=1)] = 0 return x
python
def clean_with_zeros(self,x): """ set nan and inf rows from x to zero""" x[~np.any(np.isnan(x) | np.isinf(x),axis=1)] = 0 return x
[ "def", "clean_with_zeros", "(", "self", ",", "x", ")", ":", "x", "[", "~", "np", ".", "any", "(", "np", ".", "isnan", "(", "x", ")", "|", "np", ".", "isinf", "(", "x", ")", ",", "axis", "=", "1", ")", "]", "=", "0", "return", "x" ]
set nan and inf rows from x to zero
[ "set", "nan", "and", "inf", "rows", "from", "x", "to", "zero" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/few.py#L443-L446
lacava/few
few/few.py
FEW.predict
def predict(self, testing_features): """predict on a holdout data set.""" # print("best_inds:",self._best_inds) # print("best estimator size:",self._best_estimator.coef_.shape) if self.clean: testing_features = self.impute_data(testing_features) if self._best_inds: ...
python
def predict(self, testing_features): """predict on a holdout data set.""" # print("best_inds:",self._best_inds) # print("best estimator size:",self._best_estimator.coef_.shape) if self.clean: testing_features = self.impute_data(testing_features) if self._best_inds: ...
[ "def", "predict", "(", "self", ",", "testing_features", ")", ":", "# print(\"best_inds:\",self._best_inds)", "# print(\"best estimator size:\",self._best_estimator.coef_.shape)", "if", "self", ".", "clean", ":", "testing_features", "=", "self", ".", "impute_data", "(", "tes...
predict on a holdout data set.
[ "predict", "on", "a", "holdout", "data", "set", "." ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/few.py#L448-L467
lacava/few
few/few.py
FEW.fit_predict
def fit_predict(self, features, labels): """Convenience function that fits a pipeline then predicts on the provided features Parameters ---------- features: array-like {n_samples, n_features} Feature matrix labels: array-like {n_samples} List of c...
python
def fit_predict(self, features, labels): """Convenience function that fits a pipeline then predicts on the provided features Parameters ---------- features: array-like {n_samples, n_features} Feature matrix labels: array-like {n_samples} List of c...
[ "def", "fit_predict", "(", "self", ",", "features", ",", "labels", ")", ":", "self", ".", "fit", "(", "features", ",", "labels", ")", "return", "self", ".", "predict", "(", "features", ")" ]
Convenience function that fits a pipeline then predicts on the provided features Parameters ---------- features: array-like {n_samples, n_features} Feature matrix labels: array-like {n_samples} List of class labels for prediction Returns ...
[ "Convenience", "function", "that", "fits", "a", "pipeline", "then", "predicts", "on", "the", "provided", "features" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/few.py#L469-L487
lacava/few
few/few.py
FEW.score
def score(self, testing_features, testing_labels): """estimates accuracy on testing set""" # print("test features shape:",testing_features.shape) # print("testing labels shape:",testing_labels.shape) yhat = self.predict(testing_features) return self.scoring_function(testing_label...
python
def score(self, testing_features, testing_labels): """estimates accuracy on testing set""" # print("test features shape:",testing_features.shape) # print("testing labels shape:",testing_labels.shape) yhat = self.predict(testing_features) return self.scoring_function(testing_label...
[ "def", "score", "(", "self", ",", "testing_features", ",", "testing_labels", ")", ":", "# print(\"test features shape:\",testing_features.shape)", "# print(\"testing labels shape:\",testing_labels.shape)", "yhat", "=", "self", ".", "predict", "(", "testing_features", ")", "re...
estimates accuracy on testing set
[ "estimates", "accuracy", "on", "testing", "set" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/few.py#L489-L494
lacava/few
few/few.py
FEW.export
def export(self, output_file_name): """exports engineered features Parameters ---------- output_file_name: string String containing the path and file name of the desired output file Returns ------- None """ if self._best_estimator is...
python
def export(self, output_file_name): """exports engineered features Parameters ---------- output_file_name: string String containing the path and file name of the desired output file Returns ------- None """ if self._best_estimator is...
[ "def", "export", "(", "self", ",", "output_file_name", ")", ":", "if", "self", ".", "_best_estimator", "is", "None", ":", "raise", "ValueError", "(", "'A model has not been optimized. Please call fit()'", "' first.'", ")", "# Write print_model() to file", "with", "open"...
exports engineered features Parameters ---------- output_file_name: string String containing the path and file name of the desired output file Returns ------- None
[ "exports", "engineered", "features" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/few.py#L496-L523
lacava/few
few/few.py
FEW.print_model
def print_model(self,sep='\n'): """prints model contained in best inds, if ml has a coefficient property. otherwise, prints the features generated by FEW.""" model = '' # print('ml type:',self.ml_type) # print('ml:',self._best_estimator) if self._best_inds: ...
python
def print_model(self,sep='\n'): """prints model contained in best inds, if ml has a coefficient property. otherwise, prints the features generated by FEW.""" model = '' # print('ml type:',self.ml_type) # print('ml:',self._best_estimator) if self._best_inds: ...
[ "def", "print_model", "(", "self", ",", "sep", "=", "'\\n'", ")", ":", "model", "=", "''", "# print('ml type:',self.ml_type)", "# print('ml:',self._best_estimator)", "if", "self", ".", "_best_inds", ":", "if", "self", ".", "ml_type", "==", "'GridSearchCV'", ":", ...
prints model contained in best inds, if ml has a coefficient property. otherwise, prints the features generated by FEW.
[ "prints", "model", "contained", "in", "best", "inds", "if", "ml", "has", "a", "coefficient", "property", ".", "otherwise", "prints", "the", "features", "generated", "by", "FEW", "." ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/few.py#L525-L579
lacava/few
few/few.py
FEW.valid_loc
def valid_loc(self,F=None): """returns the indices of individuals with valid fitness.""" if F is not None: return [i for i,f in enumerate(F) if np.all(f < self.max_fit) and np.all(f >= 0)] else: return [i for i,f in enumerate(self.F) if np.all(f < self.max_fit) and np.all...
python
def valid_loc(self,F=None): """returns the indices of individuals with valid fitness.""" if F is not None: return [i for i,f in enumerate(F) if np.all(f < self.max_fit) and np.all(f >= 0)] else: return [i for i,f in enumerate(self.F) if np.all(f < self.max_fit) and np.all...
[ "def", "valid_loc", "(", "self", ",", "F", "=", "None", ")", ":", "if", "F", "is", "not", "None", ":", "return", "[", "i", "for", "i", ",", "f", "in", "enumerate", "(", "F", ")", "if", "np", ".", "all", "(", "f", "<", "self", ".", "max_fit", ...
returns the indices of individuals with valid fitness.
[ "returns", "the", "indices", "of", "individuals", "with", "valid", "fitness", "." ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/few.py#L585-L590
lacava/few
few/few.py
FEW.valid
def valid(self,individuals=None,F=None): """returns the sublist of individuals with valid fitness.""" if F: valid_locs = self.valid_loc(F) else: valid_locs = self.valid_loc(self.F) if individuals: return [ind for i,ind in enumerate(individuals) if i i...
python
def valid(self,individuals=None,F=None): """returns the sublist of individuals with valid fitness.""" if F: valid_locs = self.valid_loc(F) else: valid_locs = self.valid_loc(self.F) if individuals: return [ind for i,ind in enumerate(individuals) if i i...
[ "def", "valid", "(", "self", ",", "individuals", "=", "None", ",", "F", "=", "None", ")", ":", "if", "F", ":", "valid_locs", "=", "self", ".", "valid_loc", "(", "F", ")", "else", ":", "valid_locs", "=", "self", ".", "valid_loc", "(", "self", ".", ...
returns the sublist of individuals with valid fitness.
[ "returns", "the", "sublist", "of", "individuals", "with", "valid", "fitness", "." ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/few.py#L592-L602
lacava/few
few/few.py
FEW.get_diversity
def get_diversity(self,X): """compute mean diversity of individual outputs""" # diversity in terms of cosine distances between features feature_correlations = np.zeros(X.shape[0]-1) for i in np.arange(1,X.shape[0]-1): feature_correlations[i] = max(0.0,r2_score(X[0],X[i])) ...
python
def get_diversity(self,X): """compute mean diversity of individual outputs""" # diversity in terms of cosine distances between features feature_correlations = np.zeros(X.shape[0]-1) for i in np.arange(1,X.shape[0]-1): feature_correlations[i] = max(0.0,r2_score(X[0],X[i])) ...
[ "def", "get_diversity", "(", "self", ",", "X", ")", ":", "# diversity in terms of cosine distances between features", "feature_correlations", "=", "np", ".", "zeros", "(", "X", ".", "shape", "[", "0", "]", "-", "1", ")", "for", "i", "in", "np", ".", "arange"...
compute mean diversity of individual outputs
[ "compute", "mean", "diversity", "of", "individual", "outputs" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/few.py#L622-L629
lacava/few
few/few.py
FEW.roc_auc_cv
def roc_auc_cv(self,features,labels): """returns an roc auc score depending on the underlying estimator.""" if callable(getattr(self.ml, "decision_function", None)): return np.mean([self.scoring_function(labels[test], self.pipeline.fit(features[train],labe...
python
def roc_auc_cv(self,features,labels): """returns an roc auc score depending on the underlying estimator.""" if callable(getattr(self.ml, "decision_function", None)): return np.mean([self.scoring_function(labels[test], self.pipeline.fit(features[train],labe...
[ "def", "roc_auc_cv", "(", "self", ",", "features", ",", "labels", ")", ":", "if", "callable", "(", "getattr", "(", "self", ".", "ml", ",", "\"decision_function\"", ",", "None", ")", ")", ":", "return", "np", ".", "mean", "(", "[", "self", ".", "scori...
returns an roc auc score depending on the underlying estimator.
[ "returns", "an", "roc", "auc", "score", "depending", "on", "the", "underlying", "estimator", "." ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/few.py#L631-L645
lacava/few
few/evaluation.py
divs
def divs(x,y): """safe division""" tmp = np.ones(x.shape) nonzero_y = y != 0 tmp[nonzero_y] = x[nonzero_y]/y[nonzero_y] return tmp
python
def divs(x,y): """safe division""" tmp = np.ones(x.shape) nonzero_y = y != 0 tmp[nonzero_y] = x[nonzero_y]/y[nonzero_y] return tmp
[ "def", "divs", "(", "x", ",", "y", ")", ":", "tmp", "=", "np", ".", "ones", "(", "x", ".", "shape", ")", "nonzero_y", "=", "y", "!=", "0", "tmp", "[", "nonzero_y", "]", "=", "x", "[", "nonzero_y", "]", "/", "y", "[", "nonzero_y", "]", "return...
safe division
[ "safe", "division" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/evaluation.py#L19-L24
lacava/few
few/evaluation.py
logs
def logs(x): """safe log""" tmp = np.ones(x.shape) nonzero_x = x != 0 tmp[nonzero_x] = np.log(np.abs(x[nonzero_x])) return tmp
python
def logs(x): """safe log""" tmp = np.ones(x.shape) nonzero_x = x != 0 tmp[nonzero_x] = np.log(np.abs(x[nonzero_x])) return tmp
[ "def", "logs", "(", "x", ")", ":", "tmp", "=", "np", ".", "ones", "(", "x", ".", "shape", ")", "nonzero_x", "=", "x", "!=", "0", "tmp", "[", "nonzero_x", "]", "=", "np", ".", "log", "(", "np", ".", "abs", "(", "x", "[", "nonzero_x", "]", ")...
safe log
[ "safe", "log" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/evaluation.py#L27-L32
lacava/few
few/evaluation.py
r2_score_vec
def r2_score_vec(y_true,y_pred): """ returns non-aggregate version of r2 score. based on r2_score() function from sklearn (http://sklearn.org) """ numerator = (y_true - y_pred) ** 2 denominator = (y_true - np.average(y_true)) ** 2 nonzero_denominator = denominator != 0 nonzero_numerator =...
python
def r2_score_vec(y_true,y_pred): """ returns non-aggregate version of r2 score. based on r2_score() function from sklearn (http://sklearn.org) """ numerator = (y_true - y_pred) ** 2 denominator = (y_true - np.average(y_true)) ** 2 nonzero_denominator = denominator != 0 nonzero_numerator =...
[ "def", "r2_score_vec", "(", "y_true", ",", "y_pred", ")", ":", "numerator", "=", "(", "y_true", "-", "y_pred", ")", "**", "2", "denominator", "=", "(", "y_true", "-", "np", ".", "average", "(", "y_true", ")", ")", "**", "2", "nonzero_denominator", "=",...
returns non-aggregate version of r2 score. based on r2_score() function from sklearn (http://sklearn.org)
[ "returns", "non", "-", "aggregate", "version", "of", "r2", "score", "." ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/evaluation.py#L35-L54
lacava/few
few/evaluation.py
inertia
def inertia(X,y,samples=False): """ return the within-class squared distance from the centroid""" # pdb.set_trace() if samples: # return within-class distance for each sample inertia = np.zeros(y.shape) for label in np.unique(y): inertia[y==label] = (X[y==label] - np.mean...
python
def inertia(X,y,samples=False): """ return the within-class squared distance from the centroid""" # pdb.set_trace() if samples: # return within-class distance for each sample inertia = np.zeros(y.shape) for label in np.unique(y): inertia[y==label] = (X[y==label] - np.mean...
[ "def", "inertia", "(", "X", ",", "y", ",", "samples", "=", "False", ")", ":", "# pdb.set_trace()", "if", "samples", ":", "# return within-class distance for each sample", "inertia", "=", "np", ".", "zeros", "(", "y", ".", "shape", ")", "for", "label", "in", ...
return the within-class squared distance from the centroid
[ "return", "the", "within", "-", "class", "squared", "distance", "from", "the", "centroid" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/evaluation.py#L232-L247
lacava/few
few/evaluation.py
separation
def separation(X,y,samples=False): """ return the sum of the between-class squared distance""" # pdb.set_trace() num_classes = len(np.unique(y)) total_dist = (X.max()-X.min())**2 if samples: # return intra-class distance for each sample separation = np.zeros(y.shape) for labe...
python
def separation(X,y,samples=False): """ return the sum of the between-class squared distance""" # pdb.set_trace() num_classes = len(np.unique(y)) total_dist = (X.max()-X.min())**2 if samples: # return intra-class distance for each sample separation = np.zeros(y.shape) for labe...
[ "def", "separation", "(", "X", ",", "y", ",", "samples", "=", "False", ")", ":", "# pdb.set_trace()", "num_classes", "=", "len", "(", "np", ".", "unique", "(", "y", ")", ")", "total_dist", "=", "(", "X", ".", "max", "(", ")", "-", "X", ".", "min"...
return the sum of the between-class squared distance
[ "return", "the", "sum", "of", "the", "between", "-", "class", "squared", "distance" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/evaluation.py#L249-L277
lacava/few
few/evaluation.py
fisher
def fisher(yhat,y,samples=False): """Fisher criterion""" classes = np.unique(y) mu = np.zeros(len(classes)) v = np.zeros(len(classes)) # pdb.set_trace() for c in classes.astype(int): mu[c] = np.mean(yhat[y==c]) v[c] = np.var(yhat[y==c]) if not samples: fisher = 0 ...
python
def fisher(yhat,y,samples=False): """Fisher criterion""" classes = np.unique(y) mu = np.zeros(len(classes)) v = np.zeros(len(classes)) # pdb.set_trace() for c in classes.astype(int): mu[c] = np.mean(yhat[y==c]) v[c] = np.var(yhat[y==c]) if not samples: fisher = 0 ...
[ "def", "fisher", "(", "yhat", ",", "y", ",", "samples", "=", "False", ")", ":", "classes", "=", "np", ".", "unique", "(", "y", ")", "mu", "=", "np", ".", "zeros", "(", "len", "(", "classes", ")", ")", "v", "=", "np", ".", "zeros", "(", "len",...
Fisher criterion
[ "Fisher", "criterion" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/evaluation.py#L286-L314
lacava/few
few/evaluation.py
EvaluationMixin.proper
def proper(self,x): """cleans fitness vector""" x[x < 0] = self.max_fit x[np.isnan(x)] = self.max_fit x[np.isinf(x)] = self.max_fit return x
python
def proper(self,x): """cleans fitness vector""" x[x < 0] = self.max_fit x[np.isnan(x)] = self.max_fit x[np.isinf(x)] = self.max_fit return x
[ "def", "proper", "(", "self", ",", "x", ")", ":", "x", "[", "x", "<", "0", "]", "=", "self", ".", "max_fit", "x", "[", "np", ".", "isnan", "(", "x", ")", "]", "=", "self", ".", "max_fit", "x", "[", "np", ".", "isinf", "(", "x", ")", "]", ...
cleans fitness vector
[ "cleans", "fitness", "vector" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/evaluation.py#L149-L154
lacava/few
few/evaluation.py
EvaluationMixin.safe
def safe(self,x): """removes nans and infs from outputs.""" x[np.isinf(x)] = 1 x[np.isnan(x)] = 1 return x
python
def safe(self,x): """removes nans and infs from outputs.""" x[np.isinf(x)] = 1 x[np.isnan(x)] = 1 return x
[ "def", "safe", "(", "self", ",", "x", ")", ":", "x", "[", "np", ".", "isinf", "(", "x", ")", "]", "=", "1", "x", "[", "np", ".", "isnan", "(", "x", ")", "]", "=", "1", "return", "x" ]
removes nans and infs from outputs.
[ "removes", "nans", "and", "infs", "from", "outputs", "." ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/evaluation.py#L155-L159
lacava/few
few/evaluation.py
EvaluationMixin.evaluate
def evaluate(self,n, features, stack_float, stack_bool,labels=None): """evaluate node in program""" np.seterr(all='ignore') if len(stack_float) >= n.arity['f'] and len(stack_bool) >= n.arity['b']: if n.out_type == 'f': stack_float.append( self.safe...
python
def evaluate(self,n, features, stack_float, stack_bool,labels=None): """evaluate node in program""" np.seterr(all='ignore') if len(stack_float) >= n.arity['f'] and len(stack_bool) >= n.arity['b']: if n.out_type == 'f': stack_float.append( self.safe...
[ "def", "evaluate", "(", "self", ",", "n", ",", "features", ",", "stack_float", ",", "stack_bool", ",", "labels", "=", "None", ")", ":", "np", ".", "seterr", "(", "all", "=", "'ignore'", ")", "if", "len", "(", "stack_float", ")", ">=", "n", ".", "ar...
evaluate node in program
[ "evaluate", "node", "in", "program" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/evaluation.py#L161-L178
lacava/few
few/evaluation.py
EvaluationMixin.all_finite
def all_finite(self,X): """returns true if X is finite, false, otherwise""" # Adapted from sklearn utils: _assert_all_finite(X) # First try an O(n) time, O(1) space solution for the common case that # everything is finite; fall back to O(n) space np.isfinite to prevent # false po...
python
def all_finite(self,X): """returns true if X is finite, false, otherwise""" # Adapted from sklearn utils: _assert_all_finite(X) # First try an O(n) time, O(1) space solution for the common case that # everything is finite; fall back to O(n) space np.isfinite to prevent # false po...
[ "def", "all_finite", "(", "self", ",", "X", ")", ":", "# Adapted from sklearn utils: _assert_all_finite(X)", "# First try an O(n) time, O(1) space solution for the common case that", "# everything is finite; fall back to O(n) space np.isfinite to prevent", "# false positives from overflow in s...
returns true if X is finite, false, otherwise
[ "returns", "true", "if", "X", "is", "finite", "false", "otherwise" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/evaluation.py#L180-L192
lacava/few
few/evaluation.py
EvaluationMixin.out
def out(self,I,features,labels=None,otype='f'): """computes the output for individual I""" stack_float = [] stack_bool = [] # print("stack:",I.stack) # evaulate stack over rows of features,labels # pdb.set_trace() for n in I.stack: self.evaluate(n,feat...
python
def out(self,I,features,labels=None,otype='f'): """computes the output for individual I""" stack_float = [] stack_bool = [] # print("stack:",I.stack) # evaulate stack over rows of features,labels # pdb.set_trace() for n in I.stack: self.evaluate(n,feat...
[ "def", "out", "(", "self", ",", "I", ",", "features", ",", "labels", "=", "None", ",", "otype", "=", "'f'", ")", ":", "stack_float", "=", "[", "]", "stack_bool", "=", "[", "]", "# print(\"stack:\",I.stack)", "# evaulate stack over rows of features,labels", "# ...
computes the output for individual I
[ "computes", "the", "output", "for", "individual", "I" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/evaluation.py#L194-L209
lacava/few
few/evaluation.py
EvaluationMixin.calc_fitness
def calc_fitness(self,X,labels,fit_choice,sel): """computes fitness of individual output yhat. yhat: output of a program. labels: correct outputs fit_choice: choice of fitness function """ if 'lexicase' in sel: # return list(map(lambda yhat: self.f_vec[fit_ch...
python
def calc_fitness(self,X,labels,fit_choice,sel): """computes fitness of individual output yhat. yhat: output of a program. labels: correct outputs fit_choice: choice of fitness function """ if 'lexicase' in sel: # return list(map(lambda yhat: self.f_vec[fit_ch...
[ "def", "calc_fitness", "(", "self", ",", "X", ",", "labels", ",", "fit_choice", ",", "sel", ")", ":", "if", "'lexicase'", "in", "sel", ":", "# return list(map(lambda yhat: self.f_vec[fit_choice](labels,yhat),X))", "return", "np", ".", "asarray", "(", "[", "self", ...
computes fitness of individual output yhat. yhat: output of a program. labels: correct outputs fit_choice: choice of fitness function
[ "computes", "fitness", "of", "individual", "output", "yhat", ".", "yhat", ":", "output", "of", "a", "program", ".", "labels", ":", "correct", "outputs", "fit_choice", ":", "choice", "of", "fitness", "function" ]
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/evaluation.py#L211-L228
nion-software/nionswift-io
nionswift_plugin/DM_IO/dm3_image_utils.py
imagedatadict_to_ndarray
def imagedatadict_to_ndarray(imdict): """ Converts the ImageData dictionary, imdict, to an nd image. """ arr = imdict['Data'] im = None if isinstance(arr, parse_dm3.array.array): im = numpy.asarray(arr, dtype=arr.typecode) elif isinstance(arr, parse_dm3.structarray): t = tupl...
python
def imagedatadict_to_ndarray(imdict): """ Converts the ImageData dictionary, imdict, to an nd image. """ arr = imdict['Data'] im = None if isinstance(arr, parse_dm3.array.array): im = numpy.asarray(arr, dtype=arr.typecode) elif isinstance(arr, parse_dm3.structarray): t = tupl...
[ "def", "imagedatadict_to_ndarray", "(", "imdict", ")", ":", "arr", "=", "imdict", "[", "'Data'", "]", "im", "=", "None", "if", "isinstance", "(", "arr", ",", "parse_dm3", ".", "array", ".", "array", ")", ":", "im", "=", "numpy", ".", "asarray", "(", ...
Converts the ImageData dictionary, imdict, to an nd image.
[ "Converts", "the", "ImageData", "dictionary", "imdict", "to", "an", "nd", "image", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/DM_IO/dm3_image_utils.py#L69-L89
nion-software/nionswift-io
nionswift_plugin/DM_IO/dm3_image_utils.py
ndarray_to_imagedatadict
def ndarray_to_imagedatadict(nparr): """ Convert the numpy array nparr into a suitable ImageList entry dictionary. Returns a dictionary with the appropriate Data, DataType, PixelDepth to be inserted into a dm3 tag dictionary and written to a file. """ ret = {} dm_type = None for k, v in ...
python
def ndarray_to_imagedatadict(nparr): """ Convert the numpy array nparr into a suitable ImageList entry dictionary. Returns a dictionary with the appropriate Data, DataType, PixelDepth to be inserted into a dm3 tag dictionary and written to a file. """ ret = {} dm_type = None for k, v in ...
[ "def", "ndarray_to_imagedatadict", "(", "nparr", ")", ":", "ret", "=", "{", "}", "dm_type", "=", "None", "for", "k", ",", "v", "in", "iter", "(", "dm_image_dtypes", ".", "items", "(", ")", ")", ":", "if", "v", "[", "1", "]", "==", "nparr", ".", "...
Convert the numpy array nparr into a suitable ImageList entry dictionary. Returns a dictionary with the appropriate Data, DataType, PixelDepth to be inserted into a dm3 tag dictionary and written to a file.
[ "Convert", "the", "numpy", "array", "nparr", "into", "a", "suitable", "ImageList", "entry", "dictionary", ".", "Returns", "a", "dictionary", "with", "the", "appropriate", "Data", "DataType", "PixelDepth", "to", "be", "inserted", "into", "a", "dm3", "tag", "dic...
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/DM_IO/dm3_image_utils.py#L102-L137
nion-software/nionswift-io
nionswift_plugin/DM_IO/dm3_image_utils.py
load_image
def load_image(file) -> DataAndMetadata.DataAndMetadata: """ Loads the image from the file-like object or string file. If file is a string, the file is opened and then read. Returns a numpy ndarray of our best guess for the most important image in the file. """ if isinstance(file, str) or is...
python
def load_image(file) -> DataAndMetadata.DataAndMetadata: """ Loads the image from the file-like object or string file. If file is a string, the file is opened and then read. Returns a numpy ndarray of our best guess for the most important image in the file. """ if isinstance(file, str) or is...
[ "def", "load_image", "(", "file", ")", "->", "DataAndMetadata", ".", "DataAndMetadata", ":", "if", "isinstance", "(", "file", ",", "str", ")", "or", "isinstance", "(", "file", ",", "str", ")", ":", "with", "open", "(", "file", ",", "\"rb\"", ")", "as",...
Loads the image from the file-like object or string file. If file is a string, the file is opened and then read. Returns a numpy ndarray of our best guess for the most important image in the file.
[ "Loads", "the", "image", "from", "the", "file", "-", "like", "object", "or", "string", "file", ".", "If", "file", "is", "a", "string", "the", "file", "is", "opened", "and", "then", "read", ".", "Returns", "a", "numpy", "ndarray", "of", "our", "best", ...
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/DM_IO/dm3_image_utils.py#L171-L256
nion-software/nionswift-io
nionswift_plugin/DM_IO/dm3_image_utils.py
save_image
def save_image(xdata: DataAndMetadata.DataAndMetadata, file): """ Saves the nparray data to the file-like object (or string) file. """ # we need to create a basic DM tree suitable for an image # we'll try the minimum: just an data list # doesn't work. Do we need a ImageSourceList too? # and ...
python
def save_image(xdata: DataAndMetadata.DataAndMetadata, file): """ Saves the nparray data to the file-like object (or string) file. """ # we need to create a basic DM tree suitable for an image # we'll try the minimum: just an data list # doesn't work. Do we need a ImageSourceList too? # and ...
[ "def", "save_image", "(", "xdata", ":", "DataAndMetadata", ".", "DataAndMetadata", ",", "file", ")", ":", "# we need to create a basic DM tree suitable for an image", "# we'll try the minimum: just an data list", "# doesn't work. Do we need a ImageSourceList too?", "# and a DocumentObj...
Saves the nparray data to the file-like object (or string) file.
[ "Saves", "the", "nparray", "data", "to", "the", "file", "-", "like", "object", "(", "or", "string", ")", "file", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/DM_IO/dm3_image_utils.py#L259-L361
nion-software/nionswift-io
nionswift_plugin/DM_IO/parse_dm3.py
parse_dm_header
def parse_dm_header(f, outdata=None): """ This is the start of the DM file. We check for some magic values and then treat the next entry as a tag_root If outdata is supplied, we write instead of read using the dictionary outdata as a source Hopefully parse_dm_header(newf, outdata=parse_dm_header(f)...
python
def parse_dm_header(f, outdata=None): """ This is the start of the DM file. We check for some magic values and then treat the next entry as a tag_root If outdata is supplied, we write instead of read using the dictionary outdata as a source Hopefully parse_dm_header(newf, outdata=parse_dm_header(f)...
[ "def", "parse_dm_header", "(", "f", ",", "outdata", "=", "None", ")", ":", "# filesize is sizeondisk - 16. But we have 8 bytes of zero at the end of", "# the file.", "if", "outdata", "is", "not", "None", ":", "# this means we're WRITING to the file", "if", "verbose", ":", ...
This is the start of the DM file. We check for some magic values and then treat the next entry as a tag_root If outdata is supplied, we write instead of read using the dictionary outdata as a source Hopefully parse_dm_header(newf, outdata=parse_dm_header(f)) copies f to newf
[ "This", "is", "the", "start", "of", "the", "DM", "file", ".", "We", "check", "for", "some", "magic", "values", "and", "then", "treat", "the", "next", "entry", "as", "a", "tag_root" ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/DM_IO/parse_dm3.py#L96-L151
nion-software/nionswift-io
nionswift_plugin/DM_IO/parse_dm3.py
get_structdmtypes_for_python_typeorobject
def get_structdmtypes_for_python_typeorobject(typeorobj): """ Return structchar, dmtype for the python (or numpy) type or object typeorobj. For more complex types we only return the dm type """ # not isinstance is probably a bit more lenient than 'is' # ie isinstance(x,str) is nicer than typ...
python
def get_structdmtypes_for_python_typeorobject(typeorobj): """ Return structchar, dmtype for the python (or numpy) type or object typeorobj. For more complex types we only return the dm type """ # not isinstance is probably a bit more lenient than 'is' # ie isinstance(x,str) is nicer than typ...
[ "def", "get_structdmtypes_for_python_typeorobject", "(", "typeorobj", ")", ":", "# not isinstance is probably a bit more lenient than 'is'", "# ie isinstance(x,str) is nicer than type(x) is str.", "# hence we use isinstance when available", "if", "isinstance", "(", "typeorobj", ",", "typ...
Return structchar, dmtype for the python (or numpy) type or object typeorobj. For more complex types we only return the dm type
[ "Return", "structchar", "dmtype", "for", "the", "python", "(", "or", "numpy", ")", "type", "or", "object", "typeorobj", ".", "For", "more", "complex", "types", "we", "only", "return", "the", "dm", "type" ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/DM_IO/parse_dm3.py#L331-L363
nion-software/nionswift-io
nionswift_plugin/DM_IO/parse_dm3.py
standard_dm_read
def standard_dm_read(datatype_num, desc): """ datatype_num is the number of the data type, see dm_simple_names above. desc is a (nicename, struct_char) tuple. We return a function that parses the data for us. """ nicename, structchar, types = desc def dm_read_x(f, outdata=None): """...
python
def standard_dm_read(datatype_num, desc): """ datatype_num is the number of the data type, see dm_simple_names above. desc is a (nicename, struct_char) tuple. We return a function that parses the data for us. """ nicename, structchar, types = desc def dm_read_x(f, outdata=None): """...
[ "def", "standard_dm_read", "(", "datatype_num", ",", "desc", ")", ":", "nicename", ",", "structchar", ",", "types", "=", "desc", "def", "dm_read_x", "(", "f", ",", "outdata", "=", "None", ")", ":", "\"\"\"Reads (or write if outdata is given) a simple data type.\n ...
datatype_num is the number of the data type, see dm_simple_names above. desc is a (nicename, struct_char) tuple. We return a function that parses the data for us.
[ "datatype_num", "is", "the", "number", "of", "the", "data", "type", "see", "dm_simple_names", "above", ".", "desc", "is", "a", "(", "nicename", "struct_char", ")", "tuple", ".", "We", "return", "a", "function", "that", "parses", "the", "data", "for", "us",...
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/DM_IO/parse_dm3.py#L380-L407
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
imread
def imread(files, **kwargs): """Return image data from TIFF file(s) as numpy array. Refer to the TiffFile and TiffSequence classes and their asarray functions for documentation. Parameters ---------- files : str, binary stream, or sequence File name, seekable binary stream, glob patte...
python
def imread(files, **kwargs): """Return image data from TIFF file(s) as numpy array. Refer to the TiffFile and TiffSequence classes and their asarray functions for documentation. Parameters ---------- files : str, binary stream, or sequence File name, seekable binary stream, glob patte...
[ "def", "imread", "(", "files", ",", "*", "*", "kwargs", ")", ":", "kwargs_file", "=", "parse_kwargs", "(", "kwargs", ",", "'is_ome'", ",", "'multifile'", ",", "'_useframes'", ",", "'name'", ",", "'offset'", ",", "'size'", ",", "'multifile_close'", ",", "'f...
Return image data from TIFF file(s) as numpy array. Refer to the TiffFile and TiffSequence classes and their asarray functions for documentation. Parameters ---------- files : str, binary stream, or sequence File name, seekable binary stream, glob pattern, or sequence of file name...
[ "Return", "image", "data", "from", "TIFF", "file", "(", "s", ")", "as", "numpy", "array", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L571-L615
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
imwrite
def imwrite(file, data=None, shape=None, dtype=None, **kwargs): """Write numpy array to TIFF file. Refer to the TiffWriter class and its asarray function for documentation. A BigTIFF file is created if the data size in bytes is larger than 4 GB minus 32 MB (for metadata), and 'bigtiff' is not specifie...
python
def imwrite(file, data=None, shape=None, dtype=None, **kwargs): """Write numpy array to TIFF file. Refer to the TiffWriter class and its asarray function for documentation. A BigTIFF file is created if the data size in bytes is larger than 4 GB minus 32 MB (for metadata), and 'bigtiff' is not specifie...
[ "def", "imwrite", "(", "file", ",", "data", "=", "None", ",", "shape", "=", "None", ",", "dtype", "=", "None", ",", "*", "*", "kwargs", ")", ":", "tifargs", "=", "parse_kwargs", "(", "kwargs", ",", "'append'", ",", "'bigtiff'", ",", "'byteorder'", ",...
Write numpy array to TIFF file. Refer to the TiffWriter class and its asarray function for documentation. A BigTIFF file is created if the data size in bytes is larger than 4 GB minus 32 MB (for metadata), and 'bigtiff' is not specified, and 'imagej' or 'truncate' are not enabled. Parameters ...
[ "Write", "numpy", "array", "to", "TIFF", "file", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L618-L674
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
memmap
def memmap(filename, shape=None, dtype=None, page=None, series=0, mode='r+', **kwargs): """Return memory-mapped numpy array stored in TIFF file. Memory-mapping requires data stored in native byte order, without tiling, compression, predictors, etc. If 'shape' and 'dtype' are provided, existi...
python
def memmap(filename, shape=None, dtype=None, page=None, series=0, mode='r+', **kwargs): """Return memory-mapped numpy array stored in TIFF file. Memory-mapping requires data stored in native byte order, without tiling, compression, predictors, etc. If 'shape' and 'dtype' are provided, existi...
[ "def", "memmap", "(", "filename", ",", "shape", "=", "None", ",", "dtype", "=", "None", ",", "page", "=", "None", ",", "series", "=", "0", ",", "mode", "=", "'r+'", ",", "*", "*", "kwargs", ")", ":", "if", "shape", "is", "not", "None", "and", "...
Return memory-mapped numpy array stored in TIFF file. Memory-mapping requires data stored in native byte order, without tiling, compression, predictors, etc. If 'shape' and 'dtype' are provided, existing files will be overwritten or appended to depending on the 'append' parameter. Otherwise the ima...
[ "Return", "memory", "-", "mapped", "numpy", "array", "stored", "in", "TIFF", "file", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L680-L740
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_tags
def read_tags(fh, byteorder, offsetsize, tagnames, customtags=None, maxifds=None): """Read tags from chain of IFDs and return as list of dicts. The file handle position must be at a valid IFD header. """ if offsetsize == 4: offsetformat = byteorder+'I' tagnosize = 2 ...
python
def read_tags(fh, byteorder, offsetsize, tagnames, customtags=None, maxifds=None): """Read tags from chain of IFDs and return as list of dicts. The file handle position must be at a valid IFD header. """ if offsetsize == 4: offsetformat = byteorder+'I' tagnosize = 2 ...
[ "def", "read_tags", "(", "fh", ",", "byteorder", ",", "offsetsize", ",", "tagnames", ",", "customtags", "=", "None", ",", "maxifds", "=", "None", ")", ":", "if", "offsetsize", "==", "4", ":", "offsetformat", "=", "byteorder", "+", "'I'", "tagnosize", "="...
Read tags from chain of IFDs and return as list of dicts. The file handle position must be at a valid IFD header.
[ "Read", "tags", "from", "chain", "of", "IFDs", "and", "return", "as", "list", "of", "dicts", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L7973-L8078
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_exif_ifd
def read_exif_ifd(fh, byteorder, dtype, count, offsetsize): """Read EXIF tags from file and return as dict.""" exif = read_tags(fh, byteorder, offsetsize, TIFF.EXIF_TAGS, maxifds=1) for name in ('ExifVersion', 'FlashpixVersion'): try: exif[name] = bytes2str(exif[name]) except Exc...
python
def read_exif_ifd(fh, byteorder, dtype, count, offsetsize): """Read EXIF tags from file and return as dict.""" exif = read_tags(fh, byteorder, offsetsize, TIFF.EXIF_TAGS, maxifds=1) for name in ('ExifVersion', 'FlashpixVersion'): try: exif[name] = bytes2str(exif[name]) except Exc...
[ "def", "read_exif_ifd", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "exif", "=", "read_tags", "(", "fh", ",", "byteorder", ",", "offsetsize", ",", "TIFF", ".", "EXIF_TAGS", ",", "maxifds", "=", "1", ")", "for",...
Read EXIF tags from file and return as dict.
[ "Read", "EXIF", "tags", "from", "file", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8081-L8098
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_gps_ifd
def read_gps_ifd(fh, byteorder, dtype, count, offsetsize): """Read GPS tags from file and return as dict.""" return read_tags(fh, byteorder, offsetsize, TIFF.GPS_TAGS, maxifds=1)
python
def read_gps_ifd(fh, byteorder, dtype, count, offsetsize): """Read GPS tags from file and return as dict.""" return read_tags(fh, byteorder, offsetsize, TIFF.GPS_TAGS, maxifds=1)
[ "def", "read_gps_ifd", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "return", "read_tags", "(", "fh", ",", "byteorder", ",", "offsetsize", ",", "TIFF", ".", "GPS_TAGS", ",", "maxifds", "=", "1", ")" ]
Read GPS tags from file and return as dict.
[ "Read", "GPS", "tags", "from", "file", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8101-L8103
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_interoperability_ifd
def read_interoperability_ifd(fh, byteorder, dtype, count, offsetsize): """Read Interoperability tags from file and return as dict.""" tag_names = {1: 'InteroperabilityIndex'} return read_tags(fh, byteorder, offsetsize, tag_names, maxifds=1)
python
def read_interoperability_ifd(fh, byteorder, dtype, count, offsetsize): """Read Interoperability tags from file and return as dict.""" tag_names = {1: 'InteroperabilityIndex'} return read_tags(fh, byteorder, offsetsize, tag_names, maxifds=1)
[ "def", "read_interoperability_ifd", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "tag_names", "=", "{", "1", ":", "'InteroperabilityIndex'", "}", "return", "read_tags", "(", "fh", ",", "byteorder", ",", "offsetsize", ...
Read Interoperability tags from file and return as dict.
[ "Read", "Interoperability", "tags", "from", "file", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8106-L8109
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_bytes
def read_bytes(fh, byteorder, dtype, count, offsetsize): """Read tag data from file and return as byte string.""" dtype = 'B' if dtype[-1] == 's' else byteorder+dtype[-1] count *= numpy.dtype(dtype).itemsize data = fh.read(count) if len(data) != count: log.warning('read_bytes: failed to read...
python
def read_bytes(fh, byteorder, dtype, count, offsetsize): """Read tag data from file and return as byte string.""" dtype = 'B' if dtype[-1] == 's' else byteorder+dtype[-1] count *= numpy.dtype(dtype).itemsize data = fh.read(count) if len(data) != count: log.warning('read_bytes: failed to read...
[ "def", "read_bytes", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "dtype", "=", "'B'", "if", "dtype", "[", "-", "1", "]", "==", "'s'", "else", "byteorder", "+", "dtype", "[", "-", "1", "]", "count", "*=", ...
Read tag data from file and return as byte string.
[ "Read", "tag", "data", "from", "file", "and", "return", "as", "byte", "string", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8112-L8120
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_utf8
def read_utf8(fh, byteorder, dtype, count, offsetsize): """Read tag data from file and return as unicode string.""" return fh.read(count).decode('utf-8')
python
def read_utf8(fh, byteorder, dtype, count, offsetsize): """Read tag data from file and return as unicode string.""" return fh.read(count).decode('utf-8')
[ "def", "read_utf8", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "return", "fh", ".", "read", "(", "count", ")", ".", "decode", "(", "'utf-8'", ")" ]
Read tag data from file and return as unicode string.
[ "Read", "tag", "data", "from", "file", "and", "return", "as", "unicode", "string", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8123-L8125
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_numpy
def read_numpy(fh, byteorder, dtype, count, offsetsize): """Read tag data from file and return as numpy array.""" dtype = 'b' if dtype[-1] == 's' else byteorder+dtype[-1] return fh.read_array(dtype, count)
python
def read_numpy(fh, byteorder, dtype, count, offsetsize): """Read tag data from file and return as numpy array.""" dtype = 'b' if dtype[-1] == 's' else byteorder+dtype[-1] return fh.read_array(dtype, count)
[ "def", "read_numpy", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "dtype", "=", "'b'", "if", "dtype", "[", "-", "1", "]", "==", "'s'", "else", "byteorder", "+", "dtype", "[", "-", "1", "]", "return", "fh", ...
Read tag data from file and return as numpy array.
[ "Read", "tag", "data", "from", "file", "and", "return", "as", "numpy", "array", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8128-L8131
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_colormap
def read_colormap(fh, byteorder, dtype, count, offsetsize): """Read ColorMap data from file and return as numpy array.""" cmap = fh.read_array(byteorder+dtype[-1], count) cmap.shape = (3, -1) return cmap
python
def read_colormap(fh, byteorder, dtype, count, offsetsize): """Read ColorMap data from file and return as numpy array.""" cmap = fh.read_array(byteorder+dtype[-1], count) cmap.shape = (3, -1) return cmap
[ "def", "read_colormap", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "cmap", "=", "fh", ".", "read_array", "(", "byteorder", "+", "dtype", "[", "-", "1", "]", ",", "count", ")", "cmap", ".", "shape", "=", "(...
Read ColorMap data from file and return as numpy array.
[ "Read", "ColorMap", "data", "from", "file", "and", "return", "as", "numpy", "array", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8134-L8138
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_json
def read_json(fh, byteorder, dtype, count, offsetsize): """Read JSON tag data from file and return as object.""" data = fh.read(count) try: return json.loads(unicode(stripnull(data), 'utf-8')) except ValueError: log.warning('read_json: invalid JSON')
python
def read_json(fh, byteorder, dtype, count, offsetsize): """Read JSON tag data from file and return as object.""" data = fh.read(count) try: return json.loads(unicode(stripnull(data), 'utf-8')) except ValueError: log.warning('read_json: invalid JSON')
[ "def", "read_json", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "data", "=", "fh", ".", "read", "(", "count", ")", "try", ":", "return", "json", ".", "loads", "(", "unicode", "(", "stripnull", "(", "data", ...
Read JSON tag data from file and return as object.
[ "Read", "JSON", "tag", "data", "from", "file", "and", "return", "as", "object", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8141-L8147
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_mm_header
def read_mm_header(fh, byteorder, dtype, count, offsetsize): """Read FluoView mm_header tag from file and return as dict.""" mmh = fh.read_record(TIFF.MM_HEADER, byteorder=byteorder) mmh = recarray2dict(mmh) mmh['Dimensions'] = [ (bytes2str(d[0]).strip(), d[1], d[2], d[3], bytes2str(d[4]).strip(...
python
def read_mm_header(fh, byteorder, dtype, count, offsetsize): """Read FluoView mm_header tag from file and return as dict.""" mmh = fh.read_record(TIFF.MM_HEADER, byteorder=byteorder) mmh = recarray2dict(mmh) mmh['Dimensions'] = [ (bytes2str(d[0]).strip(), d[1], d[2], d[3], bytes2str(d[4]).strip(...
[ "def", "read_mm_header", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "mmh", "=", "fh", ".", "read_record", "(", "TIFF", ".", "MM_HEADER", ",", "byteorder", "=", "byteorder", ")", "mmh", "=", "recarray2dict", "(",...
Read FluoView mm_header tag from file and return as dict.
[ "Read", "FluoView", "mm_header", "tag", "from", "file", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8150-L8160
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_uic1tag
def read_uic1tag(fh, byteorder, dtype, count, offsetsize, planecount=None): """Read MetaMorph STK UIC1Tag from file and return as dict. Return empty dictionary if planecount is unknown. """ assert dtype in ('2I', '1I') and byteorder == '<' result = {} if dtype == '2I': # pre MetaMorph ...
python
def read_uic1tag(fh, byteorder, dtype, count, offsetsize, planecount=None): """Read MetaMorph STK UIC1Tag from file and return as dict. Return empty dictionary if planecount is unknown. """ assert dtype in ('2I', '1I') and byteorder == '<' result = {} if dtype == '2I': # pre MetaMorph ...
[ "def", "read_uic1tag", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ",", "planecount", "=", "None", ")", ":", "assert", "dtype", "in", "(", "'2I'", ",", "'1I'", ")", "and", "byteorder", "==", "'<'", "result", "=", "{", ...
Read MetaMorph STK UIC1Tag from file and return as dict. Return empty dictionary if planecount is unknown.
[ "Read", "MetaMorph", "STK", "UIC1Tag", "from", "file", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8168-L8189
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_uic2tag
def read_uic2tag(fh, byteorder, dtype, planecount, offsetsize): """Read MetaMorph STK UIC2Tag from file and return as dict.""" assert dtype == '2I' and byteorder == '<' values = fh.read_array('<u4', 6*planecount).reshape(planecount, 6) return { 'ZDistance': values[:, 0] / values[:, 1], '...
python
def read_uic2tag(fh, byteorder, dtype, planecount, offsetsize): """Read MetaMorph STK UIC2Tag from file and return as dict.""" assert dtype == '2I' and byteorder == '<' values = fh.read_array('<u4', 6*planecount).reshape(planecount, 6) return { 'ZDistance': values[:, 0] / values[:, 1], '...
[ "def", "read_uic2tag", "(", "fh", ",", "byteorder", ",", "dtype", ",", "planecount", ",", "offsetsize", ")", ":", "assert", "dtype", "==", "'2I'", "and", "byteorder", "==", "'<'", "values", "=", "fh", ".", "read_array", "(", "'<u4'", ",", "6", "*", "pl...
Read MetaMorph STK UIC2Tag from file and return as dict.
[ "Read", "MetaMorph", "STK", "UIC2Tag", "from", "file", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8192-L8201
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_uic4tag
def read_uic4tag(fh, byteorder, dtype, planecount, offsetsize): """Read MetaMorph STK UIC4Tag from file and return as dict.""" assert dtype == '1I' and byteorder == '<' result = {} while True: tagid = struct.unpack('<H', fh.read(2))[0] if tagid == 0: break name, value...
python
def read_uic4tag(fh, byteorder, dtype, planecount, offsetsize): """Read MetaMorph STK UIC4Tag from file and return as dict.""" assert dtype == '1I' and byteorder == '<' result = {} while True: tagid = struct.unpack('<H', fh.read(2))[0] if tagid == 0: break name, value...
[ "def", "read_uic4tag", "(", "fh", ",", "byteorder", ",", "dtype", ",", "planecount", ",", "offsetsize", ")", ":", "assert", "dtype", "==", "'1I'", "and", "byteorder", "==", "'<'", "result", "=", "{", "}", "while", "True", ":", "tagid", "=", "struct", "...
Read MetaMorph STK UIC4Tag from file and return as dict.
[ "Read", "MetaMorph", "STK", "UIC4Tag", "from", "file", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8211-L8221
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_uic_tag
def read_uic_tag(fh, tagid, planecount, offset): """Read a single UIC tag value from file and return tag name and value. UIC1Tags use an offset. """ def read_int(count=1): value = struct.unpack('<%iI' % count, fh.read(4*count)) return value[0] if count == 1 else value try: ...
python
def read_uic_tag(fh, tagid, planecount, offset): """Read a single UIC tag value from file and return tag name and value. UIC1Tags use an offset. """ def read_int(count=1): value = struct.unpack('<%iI' % count, fh.read(4*count)) return value[0] if count == 1 else value try: ...
[ "def", "read_uic_tag", "(", "fh", ",", "tagid", ",", "planecount", ",", "offset", ")", ":", "def", "read_int", "(", "count", "=", "1", ")", ":", "value", "=", "struct", ".", "unpack", "(", "'<%iI'", "%", "count", ",", "fh", ".", "read", "(", "4", ...
Read a single UIC tag value from file and return tag name and value. UIC1Tags use an offset.
[ "Read", "a", "single", "UIC", "tag", "value", "from", "file", "and", "return", "tag", "name", "and", "value", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8224-L8316
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_uic_image_property
def read_uic_image_property(fh): """Read UIC ImagePropertyEx tag from file and return as dict.""" # TODO: test this size = struct.unpack('B', fh.read(1))[0] name = struct.unpack('%is' % size, fh.read(size))[0][:-1] flags, prop = struct.unpack('<IB', fh.read(5)) if prop == 1: value = stru...
python
def read_uic_image_property(fh): """Read UIC ImagePropertyEx tag from file and return as dict.""" # TODO: test this size = struct.unpack('B', fh.read(1))[0] name = struct.unpack('%is' % size, fh.read(size))[0][:-1] flags, prop = struct.unpack('<IB', fh.read(5)) if prop == 1: value = stru...
[ "def", "read_uic_image_property", "(", "fh", ")", ":", "# TODO: test this", "size", "=", "struct", ".", "unpack", "(", "'B'", ",", "fh", ".", "read", "(", "1", ")", ")", "[", "0", "]", "name", "=", "struct", ".", "unpack", "(", "'%is'", "%", "size", ...
Read UIC ImagePropertyEx tag from file and return as dict.
[ "Read", "UIC", "ImagePropertyEx", "tag", "from", "file", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8319-L8331
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_cz_lsminfo
def read_cz_lsminfo(fh, byteorder, dtype, count, offsetsize): """Read CZ_LSMINFO tag from file and return as dict.""" assert byteorder == '<' magic_number, structure_size = struct.unpack('<II', fh.read(8)) if magic_number not in (50350412, 67127628): raise ValueError('invalid CZ_LSMINFO structur...
python
def read_cz_lsminfo(fh, byteorder, dtype, count, offsetsize): """Read CZ_LSMINFO tag from file and return as dict.""" assert byteorder == '<' magic_number, structure_size = struct.unpack('<II', fh.read(8)) if magic_number not in (50350412, 67127628): raise ValueError('invalid CZ_LSMINFO structur...
[ "def", "read_cz_lsminfo", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "assert", "byteorder", "==", "'<'", "magic_number", ",", "structure_size", "=", "struct", ".", "unpack", "(", "'<II'", ",", "fh", ".", "read", ...
Read CZ_LSMINFO tag from file and return as dict.
[ "Read", "CZ_LSMINFO", "tag", "from", "file", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8334-L8369
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_lsm_floatpairs
def read_lsm_floatpairs(fh): """Read LSM sequence of float pairs from file and return as list.""" size = struct.unpack('<i', fh.read(4))[0] return fh.read_array('<2f8', count=size)
python
def read_lsm_floatpairs(fh): """Read LSM sequence of float pairs from file and return as list.""" size = struct.unpack('<i', fh.read(4))[0] return fh.read_array('<2f8', count=size)
[ "def", "read_lsm_floatpairs", "(", "fh", ")", ":", "size", "=", "struct", ".", "unpack", "(", "'<i'", ",", "fh", ".", "read", "(", "4", ")", ")", "[", "0", "]", "return", "fh", ".", "read_array", "(", "'<2f8'", ",", "count", "=", "size", ")" ]
Read LSM sequence of float pairs from file and return as list.
[ "Read", "LSM", "sequence", "of", "float", "pairs", "from", "file", "and", "return", "as", "list", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8372-L8375
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_lsm_positions
def read_lsm_positions(fh): """Read LSM positions from file and return as list.""" size = struct.unpack('<I', fh.read(4))[0] return fh.read_array('<2f8', count=size)
python
def read_lsm_positions(fh): """Read LSM positions from file and return as list.""" size = struct.unpack('<I', fh.read(4))[0] return fh.read_array('<2f8', count=size)
[ "def", "read_lsm_positions", "(", "fh", ")", ":", "size", "=", "struct", ".", "unpack", "(", "'<I'", ",", "fh", ".", "read", "(", "4", ")", ")", "[", "0", "]", "return", "fh", ".", "read_array", "(", "'<2f8'", ",", "count", "=", "size", ")" ]
Read LSM positions from file and return as list.
[ "Read", "LSM", "positions", "from", "file", "and", "return", "as", "list", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8378-L8381
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_lsm_timestamps
def read_lsm_timestamps(fh): """Read LSM time stamps from file and return as list.""" size, count = struct.unpack('<ii', fh.read(8)) if size != (8 + 8 * count): log.warning('read_lsm_timestamps: invalid LSM TimeStamps block') return [] # return struct.unpack('<%dd' % count, fh.read(8*cou...
python
def read_lsm_timestamps(fh): """Read LSM time stamps from file and return as list.""" size, count = struct.unpack('<ii', fh.read(8)) if size != (8 + 8 * count): log.warning('read_lsm_timestamps: invalid LSM TimeStamps block') return [] # return struct.unpack('<%dd' % count, fh.read(8*cou...
[ "def", "read_lsm_timestamps", "(", "fh", ")", ":", "size", ",", "count", "=", "struct", ".", "unpack", "(", "'<ii'", ",", "fh", ".", "read", "(", "8", ")", ")", "if", "size", "!=", "(", "8", "+", "8", "*", "count", ")", ":", "log", ".", "warnin...
Read LSM time stamps from file and return as list.
[ "Read", "LSM", "time", "stamps", "from", "file", "and", "return", "as", "list", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8384-L8391
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_lsm_eventlist
def read_lsm_eventlist(fh): """Read LSM events from file and return as list of (time, type, text).""" count = struct.unpack('<II', fh.read(8))[1] events = [] while count > 0: esize, etime, etype = struct.unpack('<IdI', fh.read(16)) etext = bytes2str(stripnull(fh.read(esize - 16))) ...
python
def read_lsm_eventlist(fh): """Read LSM events from file and return as list of (time, type, text).""" count = struct.unpack('<II', fh.read(8))[1] events = [] while count > 0: esize, etime, etype = struct.unpack('<IdI', fh.read(16)) etext = bytes2str(stripnull(fh.read(esize - 16))) ...
[ "def", "read_lsm_eventlist", "(", "fh", ")", ":", "count", "=", "struct", ".", "unpack", "(", "'<II'", ",", "fh", ".", "read", "(", "8", ")", ")", "[", "1", "]", "events", "=", "[", "]", "while", "count", ">", "0", ":", "esize", ",", "etime", "...
Read LSM events from file and return as list of (time, type, text).
[ "Read", "LSM", "events", "from", "file", "and", "return", "as", "list", "of", "(", "time", "type", "text", ")", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8394-L8403
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_lsm_channelcolors
def read_lsm_channelcolors(fh): """Read LSM ChannelColors structure from file and return as dict.""" result = {'Mono': False, 'Colors': [], 'ColorNames': []} pos = fh.tell() (size, ncolors, nnames, coffset, noffset, mono) = struct.unpack('<IIIIII', fh.read(24)) if ncolors != nnames: log...
python
def read_lsm_channelcolors(fh): """Read LSM ChannelColors structure from file and return as dict.""" result = {'Mono': False, 'Colors': [], 'ColorNames': []} pos = fh.tell() (size, ncolors, nnames, coffset, noffset, mono) = struct.unpack('<IIIIII', fh.read(24)) if ncolors != nnames: log...
[ "def", "read_lsm_channelcolors", "(", "fh", ")", ":", "result", "=", "{", "'Mono'", ":", "False", ",", "'Colors'", ":", "[", "]", ",", "'ColorNames'", ":", "[", "]", "}", "pos", "=", "fh", ".", "tell", "(", ")", "(", "size", ",", "ncolors", ",", ...
Read LSM ChannelColors structure from file and return as dict.
[ "Read", "LSM", "ChannelColors", "structure", "from", "file", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8406-L8430
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_lsm_scaninfo
def read_lsm_scaninfo(fh): """Read LSM ScanInfo structure from file and return as dict.""" block = {} blocks = [block] unpack = struct.unpack if struct.unpack('<I', fh.read(4))[0] != 0x10000000: # not a Recording sub block log.warning('read_lsm_scaninfo: invalid LSM ScanInfo structur...
python
def read_lsm_scaninfo(fh): """Read LSM ScanInfo structure from file and return as dict.""" block = {} blocks = [block] unpack = struct.unpack if struct.unpack('<I', fh.read(4))[0] != 0x10000000: # not a Recording sub block log.warning('read_lsm_scaninfo: invalid LSM ScanInfo structur...
[ "def", "read_lsm_scaninfo", "(", "fh", ")", ":", "block", "=", "{", "}", "blocks", "=", "[", "block", "]", "unpack", "=", "struct", ".", "unpack", "if", "struct", ".", "unpack", "(", "'<I'", ",", "fh", ".", "read", "(", "4", ")", ")", "[", "0", ...
Read LSM ScanInfo structure from file and return as dict.
[ "Read", "LSM", "ScanInfo", "structure", "from", "file", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8433-L8478
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_sis
def read_sis(fh, byteorder, dtype, count, offsetsize): """Read OlympusSIS structure and return as dict. No specification is avaliable. Only few fields are known. """ result = {} (magic, _, minute, hour, day, month, year, _, name, tagcount ) = struct.unpack('<4s6shhhhh6s32sh', fh.read(60)) ...
python
def read_sis(fh, byteorder, dtype, count, offsetsize): """Read OlympusSIS structure and return as dict. No specification is avaliable. Only few fields are known. """ result = {} (magic, _, minute, hour, day, month, year, _, name, tagcount ) = struct.unpack('<4s6shhhhh6s32sh', fh.read(60)) ...
[ "def", "read_sis", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "result", "=", "{", "}", "(", "magic", ",", "_", ",", "minute", ",", "hour", ",", "day", ",", "month", ",", "year", ",", "_", ",", "name", ...
Read OlympusSIS structure and return as dict. No specification is avaliable. Only few fields are known.
[ "Read", "OlympusSIS", "structure", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8481-L8527
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_sis_ini
def read_sis_ini(fh, byteorder, dtype, count, offsetsize): """Read OlympusSIS INI string and return as dict.""" inistr = fh.read(count) inistr = bytes2str(stripnull(inistr)) try: return olympusini_metadata(inistr) except Exception as exc: log.warning('olympusini_metadata: %s: %s', ex...
python
def read_sis_ini(fh, byteorder, dtype, count, offsetsize): """Read OlympusSIS INI string and return as dict.""" inistr = fh.read(count) inistr = bytes2str(stripnull(inistr)) try: return olympusini_metadata(inistr) except Exception as exc: log.warning('olympusini_metadata: %s: %s', ex...
[ "def", "read_sis_ini", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "inistr", "=", "fh", ".", "read", "(", "count", ")", "inistr", "=", "bytes2str", "(", "stripnull", "(", "inistr", ")", ")", "try", ":", "retu...
Read OlympusSIS INI string and return as dict.
[ "Read", "OlympusSIS", "INI", "string", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8530-L8538
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_tvips_header
def read_tvips_header(fh, byteorder, dtype, count, offsetsize): """Read TVIPS EM-MENU headers and return as dict.""" result = {} header = fh.read_record(TIFF.TVIPS_HEADER_V1, byteorder=byteorder) for name, typestr in TIFF.TVIPS_HEADER_V1: result[name] = header[name].tolist() if header['Versi...
python
def read_tvips_header(fh, byteorder, dtype, count, offsetsize): """Read TVIPS EM-MENU headers and return as dict.""" result = {} header = fh.read_record(TIFF.TVIPS_HEADER_V1, byteorder=byteorder) for name, typestr in TIFF.TVIPS_HEADER_V1: result[name] = header[name].tolist() if header['Versi...
[ "def", "read_tvips_header", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "result", "=", "{", "}", "header", "=", "fh", ".", "read_record", "(", "TIFF", ".", "TVIPS_HEADER_V1", ",", "byteorder", "=", "byteorder", "...
Read TVIPS EM-MENU headers and return as dict.
[ "Read", "TVIPS", "EM", "-", "MENU", "headers", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8541-L8566
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_fei_metadata
def read_fei_metadata(fh, byteorder, dtype, count, offsetsize): """Read FEI SFEG/HELIOS headers and return as dict.""" result = {} section = {} data = bytes2str(stripnull(fh.read(count))) for line in data.splitlines(): line = line.strip() if line.startswith('['): section ...
python
def read_fei_metadata(fh, byteorder, dtype, count, offsetsize): """Read FEI SFEG/HELIOS headers and return as dict.""" result = {} section = {} data = bytes2str(stripnull(fh.read(count))) for line in data.splitlines(): line = line.strip() if line.startswith('['): section ...
[ "def", "read_fei_metadata", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "result", "=", "{", "}", "section", "=", "{", "}", "data", "=", "bytes2str", "(", "stripnull", "(", "fh", ".", "read", "(", "count", ")"...
Read FEI SFEG/HELIOS headers and return as dict.
[ "Read", "FEI", "SFEG", "/", "HELIOS", "headers", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8569-L8585
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_cz_sem
def read_cz_sem(fh, byteorder, dtype, count, offsetsize): """Read Zeiss SEM tag and return as dict. See https://sourceforge.net/p/gwyddion/mailman/message/29275000/ for unnamed values. """ result = {'': ()} key = None data = bytes2str(stripnull(fh.read(count))) for line in data.splitli...
python
def read_cz_sem(fh, byteorder, dtype, count, offsetsize): """Read Zeiss SEM tag and return as dict. See https://sourceforge.net/p/gwyddion/mailman/message/29275000/ for unnamed values. """ result = {'': ()} key = None data = bytes2str(stripnull(fh.read(count))) for line in data.splitli...
[ "def", "read_cz_sem", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "result", "=", "{", "''", ":", "(", ")", "}", "key", "=", "None", "data", "=", "bytes2str", "(", "stripnull", "(", "fh", ".", "read", "(", ...
Read Zeiss SEM tag and return as dict. See https://sourceforge.net/p/gwyddion/mailman/message/29275000/ for unnamed values.
[ "Read", "Zeiss", "SEM", "tag", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8588-L8631
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_nih_image_header
def read_nih_image_header(fh, byteorder, dtype, count, offsetsize): """Read NIH_IMAGE_HEADER tag from file and return as dict.""" a = fh.read_record(TIFF.NIH_IMAGE_HEADER, byteorder=byteorder) a = a.newbyteorder(byteorder) a = recarray2dict(a) a['XUnit'] = a['XUnit'][:a['XUnitSize']] a['UM'] = a...
python
def read_nih_image_header(fh, byteorder, dtype, count, offsetsize): """Read NIH_IMAGE_HEADER tag from file and return as dict.""" a = fh.read_record(TIFF.NIH_IMAGE_HEADER, byteorder=byteorder) a = a.newbyteorder(byteorder) a = recarray2dict(a) a['XUnit'] = a['XUnit'][:a['XUnitSize']] a['UM'] = a...
[ "def", "read_nih_image_header", "(", "fh", ",", "byteorder", ",", "dtype", ",", "count", ",", "offsetsize", ")", ":", "a", "=", "fh", ".", "read_record", "(", "TIFF", ".", "NIH_IMAGE_HEADER", ",", "byteorder", "=", "byteorder", ")", "a", "=", "a", ".", ...
Read NIH_IMAGE_HEADER tag from file and return as dict.
[ "Read", "NIH_IMAGE_HEADER", "tag", "from", "file", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8634-L8641
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_scanimage_metadata
def read_scanimage_metadata(fh): """Read ScanImage BigTIFF v3 static and ROI metadata from open file. Return non-varying frame data as dict and ROI group data as JSON. The settings can be used to read image data and metadata without parsing the TIFF file. Raise ValueError if file does not contain...
python
def read_scanimage_metadata(fh): """Read ScanImage BigTIFF v3 static and ROI metadata from open file. Return non-varying frame data as dict and ROI group data as JSON. The settings can be used to read image data and metadata without parsing the TIFF file. Raise ValueError if file does not contain...
[ "def", "read_scanimage_metadata", "(", "fh", ")", ":", "fh", ".", "seek", "(", "0", ")", "try", ":", "byteorder", ",", "version", "=", "struct", ".", "unpack", "(", "'<2sH'", ",", "fh", ".", "read", "(", "4", ")", ")", "if", "byteorder", "!=", "b'I...
Read ScanImage BigTIFF v3 static and ROI metadata from open file. Return non-varying frame data as dict and ROI group data as JSON. The settings can be used to read image data and metadata without parsing the TIFF file. Raise ValueError if file does not contain valid ScanImage v3 metadata.
[ "Read", "ScanImage", "BigTIFF", "v3", "static", "and", "ROI", "metadata", "from", "open", "file", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8644-L8669
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
read_micromanager_metadata
def read_micromanager_metadata(fh): """Read MicroManager non-TIFF settings from open file and return as dict. The settings can be used to read image data without parsing the TIFF file. Raise ValueError if the file does not contain valid MicroManager metadata. """ fh.seek(0) try: byteo...
python
def read_micromanager_metadata(fh): """Read MicroManager non-TIFF settings from open file and return as dict. The settings can be used to read image data without parsing the TIFF file. Raise ValueError if the file does not contain valid MicroManager metadata. """ fh.seek(0) try: byteo...
[ "def", "read_micromanager_metadata", "(", "fh", ")", ":", "fh", ".", "seek", "(", "0", ")", "try", ":", "byteorder", "=", "{", "b'II'", ":", "'<'", ",", "b'MM'", ":", "'>'", "}", "[", "fh", ".", "read", "(", "2", ")", "]", "except", "IndexError", ...
Read MicroManager non-TIFF settings from open file and return as dict. The settings can be used to read image data without parsing the TIFF file. Raise ValueError if the file does not contain valid MicroManager metadata.
[ "Read", "MicroManager", "non", "-", "TIFF", "settings", "from", "open", "file", "and", "return", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8672-L8725
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
imagej_metadata_tag
def imagej_metadata_tag(metadata, byteorder): """Return IJMetadata and IJMetadataByteCounts tags from metadata dict. The tags can be passed to the TiffWriter.save function as extratags. The metadata dict may contain the following keys and values: Info : str Human-readable information ...
python
def imagej_metadata_tag(metadata, byteorder): """Return IJMetadata and IJMetadataByteCounts tags from metadata dict. The tags can be passed to the TiffWriter.save function as extratags. The metadata dict may contain the following keys and values: Info : str Human-readable information ...
[ "def", "imagej_metadata_tag", "(", "metadata", ",", "byteorder", ")", ":", "header", "=", "[", "{", "'>'", ":", "b'IJIJ'", ",", "'<'", ":", "b'JIJI'", "}", "[", "byteorder", "]", "]", "bytecounts", "=", "[", "0", "]", "body", "=", "[", "]", "def", ...
Return IJMetadata and IJMetadataByteCounts tags from metadata dict. The tags can be passed to the TiffWriter.save function as extratags. The metadata dict may contain the following keys and values: Info : str Human-readable information as string. Labels : sequence of str ...
[ "Return", "IJMetadata", "and", "IJMetadataByteCounts", "tags", "from", "metadata", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8738-L8812
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
imagej_metadata
def imagej_metadata(data, bytecounts, byteorder): """Return IJMetadata tag value as dict. The 'Info' string can have multiple formats, e.g. OIF or ScanImage, that might be parsed into dicts using the matlabstr2py or oiffile.SettingsFile functions. """ def _string(data, byteorder): retu...
python
def imagej_metadata(data, bytecounts, byteorder): """Return IJMetadata tag value as dict. The 'Info' string can have multiple formats, e.g. OIF or ScanImage, that might be parsed into dicts using the matlabstr2py or oiffile.SettingsFile functions. """ def _string(data, byteorder): retu...
[ "def", "imagej_metadata", "(", "data", ",", "bytecounts", ",", "byteorder", ")", ":", "def", "_string", "(", "data", ",", "byteorder", ")", ":", "return", "data", ".", "decode", "(", "'utf-16'", "+", "{", "'>'", ":", "'be'", ",", "'<'", ":", "'le'", ...
Return IJMetadata tag value as dict. The 'Info' string can have multiple formats, e.g. OIF or ScanImage, that might be parsed into dicts using the matlabstr2py or oiffile.SettingsFile functions.
[ "Return", "IJMetadata", "tag", "value", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8815-L8870
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
imagej_description_metadata
def imagej_description_metadata(description): """Return metatata from ImageJ image description as dict. Raise ValueError if not a valid ImageJ description. >>> description = 'ImageJ=1.11a\\nimages=510\\nhyperstack=true\\n' >>> imagej_description_metadata(description) # doctest: +SKIP {'ImageJ': '...
python
def imagej_description_metadata(description): """Return metatata from ImageJ image description as dict. Raise ValueError if not a valid ImageJ description. >>> description = 'ImageJ=1.11a\\nimages=510\\nhyperstack=true\\n' >>> imagej_description_metadata(description) # doctest: +SKIP {'ImageJ': '...
[ "def", "imagej_description_metadata", "(", "description", ")", ":", "def", "_bool", "(", "val", ")", ":", "return", "{", "'true'", ":", "True", ",", "'false'", ":", "False", "}", "[", "val", ".", "lower", "(", ")", "]", "result", "=", "{", "}", "for"...
Return metatata from ImageJ image description as dict. Raise ValueError if not a valid ImageJ description. >>> description = 'ImageJ=1.11a\\nimages=510\\nhyperstack=true\\n' >>> imagej_description_metadata(description) # doctest: +SKIP {'ImageJ': '1.11a', 'images': 510, 'hyperstack': True}
[ "Return", "metatata", "from", "ImageJ", "image", "description", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8873-L8904
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
imagej_description
def imagej_description(shape, rgb=None, colormaped=False, version=None, hyperstack=None, mode=None, loop=None, **kwargs): """Return ImageJ image description from data shape. ImageJ can handle up to 6 dimensions in order TZCYXS. >>> imagej_description((51, 5, 2, 196, 171)) # doctest...
python
def imagej_description(shape, rgb=None, colormaped=False, version=None, hyperstack=None, mode=None, loop=None, **kwargs): """Return ImageJ image description from data shape. ImageJ can handle up to 6 dimensions in order TZCYXS. >>> imagej_description((51, 5, 2, 196, 171)) # doctest...
[ "def", "imagej_description", "(", "shape", ",", "rgb", "=", "None", ",", "colormaped", "=", "False", ",", "version", "=", "None", ",", "hyperstack", "=", "None", ",", "mode", "=", "None", ",", "loop", "=", "None", ",", "*", "*", "kwargs", ")", ":", ...
Return ImageJ image description from data shape. ImageJ can handle up to 6 dimensions in order TZCYXS. >>> imagej_description((51, 5, 2, 196, 171)) # doctest: +SKIP ImageJ=1.11a images=510 channels=2 slices=5 frames=51 hyperstack=true mode=grayscale loop=false
[ "Return", "ImageJ", "image", "description", "from", "data", "shape", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8907-L8956
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
imagej_shape
def imagej_shape(shape, rgb=None): """Return shape normalized to 6D ImageJ hyperstack TZCYXS. Raise ValueError if not a valid ImageJ hyperstack shape. >>> imagej_shape((2, 3, 4, 5, 3), False) (2, 3, 4, 5, 3, 1) """ shape = tuple(int(i) for i in shape) ndim = len(shape) if 1 > ndim > 6...
python
def imagej_shape(shape, rgb=None): """Return shape normalized to 6D ImageJ hyperstack TZCYXS. Raise ValueError if not a valid ImageJ hyperstack shape. >>> imagej_shape((2, 3, 4, 5, 3), False) (2, 3, 4, 5, 3, 1) """ shape = tuple(int(i) for i in shape) ndim = len(shape) if 1 > ndim > 6...
[ "def", "imagej_shape", "(", "shape", ",", "rgb", "=", "None", ")", ":", "shape", "=", "tuple", "(", "int", "(", "i", ")", "for", "i", "in", "shape", ")", "ndim", "=", "len", "(", "shape", ")", "if", "1", ">", "ndim", ">", "6", ":", "raise", "...
Return shape normalized to 6D ImageJ hyperstack TZCYXS. Raise ValueError if not a valid ImageJ hyperstack shape. >>> imagej_shape((2, 3, 4, 5, 3), False) (2, 3, 4, 5, 3, 1)
[ "Return", "shape", "normalized", "to", "6D", "ImageJ", "hyperstack", "TZCYXS", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8959-L8980
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
json_description
def json_description(shape, **metadata): """Return JSON image description from data shape and other metadata. Return UTF-8 encoded JSON. >>> json_description((256, 256, 3), axes='YXS') # doctest: +SKIP b'{"shape": [256, 256, 3], "axes": "YXS"}' """ metadata.update(shape=shape) return jso...
python
def json_description(shape, **metadata): """Return JSON image description from data shape and other metadata. Return UTF-8 encoded JSON. >>> json_description((256, 256, 3), axes='YXS') # doctest: +SKIP b'{"shape": [256, 256, 3], "axes": "YXS"}' """ metadata.update(shape=shape) return jso...
[ "def", "json_description", "(", "shape", ",", "*", "*", "metadata", ")", ":", "metadata", ".", "update", "(", "shape", "=", "shape", ")", "return", "json", ".", "dumps", "(", "metadata", ")" ]
Return JSON image description from data shape and other metadata. Return UTF-8 encoded JSON. >>> json_description((256, 256, 3), axes='YXS') # doctest: +SKIP b'{"shape": [256, 256, 3], "axes": "YXS"}'
[ "Return", "JSON", "image", "description", "from", "data", "shape", "and", "other", "metadata", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8983-L8993
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
json_description_metadata
def json_description_metadata(description): """Return metatata from JSON formated image description as dict. Raise ValuError if description is of unknown format. >>> description = '{"shape": [256, 256, 3], "axes": "YXS"}' >>> json_description_metadata(description) # doctest: +SKIP {'shape': [256,...
python
def json_description_metadata(description): """Return metatata from JSON formated image description as dict. Raise ValuError if description is of unknown format. >>> description = '{"shape": [256, 256, 3], "axes": "YXS"}' >>> json_description_metadata(description) # doctest: +SKIP {'shape': [256,...
[ "def", "json_description_metadata", "(", "description", ")", ":", "if", "description", "[", ":", "6", "]", "==", "'shape='", ":", "# old-style 'shaped' description; not JSON", "shape", "=", "tuple", "(", "int", "(", "i", ")", "for", "i", "in", "description", "...
Return metatata from JSON formated image description as dict. Raise ValuError if description is of unknown format. >>> description = '{"shape": [256, 256, 3], "axes": "YXS"}' >>> json_description_metadata(description) # doctest: +SKIP {'shape': [256, 256, 3], 'axes': 'YXS'} >>> json_description_m...
[ "Return", "metatata", "from", "JSON", "formated", "image", "description", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8996-L9015
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
fluoview_description_metadata
def fluoview_description_metadata(description, ignoresections=None): """Return metatata from FluoView image description as dict. The FluoView image description format is unspecified. Expect failures. >>> descr = ('[Intensity Mapping]\\nMap Ch0: Range=00000 to 02047\\n' ... '[Intensity Mapping...
python
def fluoview_description_metadata(description, ignoresections=None): """Return metatata from FluoView image description as dict. The FluoView image description format is unspecified. Expect failures. >>> descr = ('[Intensity Mapping]\\nMap Ch0: Range=00000 to 02047\\n' ... '[Intensity Mapping...
[ "def", "fluoview_description_metadata", "(", "description", ",", "ignoresections", "=", "None", ")", ":", "if", "not", "description", ".", "startswith", "(", "'['", ")", ":", "raise", "ValueError", "(", "'invalid FluoView image description'", ")", "if", "ignoresecti...
Return metatata from FluoView image description as dict. The FluoView image description format is unspecified. Expect failures. >>> descr = ('[Intensity Mapping]\\nMap Ch0: Range=00000 to 02047\\n' ... '[Intensity Mapping End]') >>> fluoview_description_metadata(descr) {'Intensity Mapping...
[ "Return", "metatata", "from", "FluoView", "image", "description", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9018-L9081
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
pilatus_description_metadata
def pilatus_description_metadata(description): """Return metatata from Pilatus image description as dict. Return metadata from Pilatus pixel array detectors by Dectris, created by camserver or TVX software. >>> pilatus_description_metadata('# Pixel_size 172e-6 m x 172e-6 m') {'Pixel_size': (0.0001...
python
def pilatus_description_metadata(description): """Return metatata from Pilatus image description as dict. Return metadata from Pilatus pixel array detectors by Dectris, created by camserver or TVX software. >>> pilatus_description_metadata('# Pixel_size 172e-6 m x 172e-6 m') {'Pixel_size': (0.0001...
[ "def", "pilatus_description_metadata", "(", "description", ")", ":", "result", "=", "{", "}", "if", "not", "description", ".", "startswith", "(", "'# '", ")", ":", "return", "result", "for", "c", "in", "'#:=,()'", ":", "description", "=", "description", ".",...
Return metatata from Pilatus image description as dict. Return metadata from Pilatus pixel array detectors by Dectris, created by camserver or TVX software. >>> pilatus_description_metadata('# Pixel_size 172e-6 m x 172e-6 m') {'Pixel_size': (0.000172, 0.000172)}
[ "Return", "metatata", "from", "Pilatus", "image", "description", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9084-L9125
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
svs_description_metadata
def svs_description_metadata(description): """Return metatata from Aperio image description as dict. The Aperio image description format is unspecified. Expect failures. >>> svs_description_metadata('Aperio Image Library v1.0') {'Aperio Image Library': 'v1.0'} """ if not description.startswit...
python
def svs_description_metadata(description): """Return metatata from Aperio image description as dict. The Aperio image description format is unspecified. Expect failures. >>> svs_description_metadata('Aperio Image Library v1.0') {'Aperio Image Library': 'v1.0'} """ if not description.startswit...
[ "def", "svs_description_metadata", "(", "description", ")", ":", "if", "not", "description", ".", "startswith", "(", "'Aperio Image Library '", ")", ":", "raise", "ValueError", "(", "'invalid Aperio image description'", ")", "result", "=", "{", "}", "lines", "=", ...
Return metatata from Aperio image description as dict. The Aperio image description format is unspecified. Expect failures. >>> svs_description_metadata('Aperio Image Library v1.0') {'Aperio Image Library': 'v1.0'}
[ "Return", "metatata", "from", "Aperio", "image", "description", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9128-L9150
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
stk_description_metadata
def stk_description_metadata(description): """Return metadata from MetaMorph image description as list of dict. The MetaMorph image description format is unspecified. Expect failures. """ description = description.strip() if not description: return [] try: description = bytes2s...
python
def stk_description_metadata(description): """Return metadata from MetaMorph image description as list of dict. The MetaMorph image description format is unspecified. Expect failures. """ description = description.strip() if not description: return [] try: description = bytes2s...
[ "def", "stk_description_metadata", "(", "description", ")", ":", "description", "=", "description", ".", "strip", "(", ")", "if", "not", "description", ":", "return", "[", "]", "try", ":", "description", "=", "bytes2str", "(", "description", ")", "except", "...
Return metadata from MetaMorph image description as list of dict. The MetaMorph image description format is unspecified. Expect failures.
[ "Return", "metadata", "from", "MetaMorph", "image", "description", "as", "list", "of", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9153-L9184
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
metaseries_description_metadata
def metaseries_description_metadata(description): """Return metatata from MetaSeries image description as dict.""" if not description.startswith('<MetaData>'): raise ValueError('invalid MetaSeries image description') from xml.etree import cElementTree as etree # delayed import root = etree.fro...
python
def metaseries_description_metadata(description): """Return metatata from MetaSeries image description as dict.""" if not description.startswith('<MetaData>'): raise ValueError('invalid MetaSeries image description') from xml.etree import cElementTree as etree # delayed import root = etree.fro...
[ "def", "metaseries_description_metadata", "(", "description", ")", ":", "if", "not", "description", ".", "startswith", "(", "'<MetaData>'", ")", ":", "raise", "ValueError", "(", "'invalid MetaSeries image description'", ")", "from", "xml", ".", "etree", "import", "c...
Return metatata from MetaSeries image description as dict.
[ "Return", "metatata", "from", "MetaSeries", "image", "description", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9187-L9217
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
scanimage_artist_metadata
def scanimage_artist_metadata(artist): """Return metatata from ScanImage artist tag as dict.""" try: return json.loads(artist) except ValueError as exc: log.warning('scanimage_artist_metadata: %s: %s', exc.__class__.__name__, exc)
python
def scanimage_artist_metadata(artist): """Return metatata from ScanImage artist tag as dict.""" try: return json.loads(artist) except ValueError as exc: log.warning('scanimage_artist_metadata: %s: %s', exc.__class__.__name__, exc)
[ "def", "scanimage_artist_metadata", "(", "artist", ")", ":", "try", ":", "return", "json", ".", "loads", "(", "artist", ")", "except", "ValueError", "as", "exc", ":", "log", ".", "warning", "(", "'scanimage_artist_metadata: %s: %s'", ",", "exc", ".", "__class_...
Return metatata from ScanImage artist tag as dict.
[ "Return", "metatata", "from", "ScanImage", "artist", "tag", "as", "dict", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9225-L9231
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
olympusini_metadata
def olympusini_metadata(inistr): """Return OlympusSIS metadata from INI string. No documentation is available. """ def keyindex(key): # split key into name and index index = 0 i = len(key.rstrip('0123456789')) if i < len(key): index = int(key[i:]) - 1 ...
python
def olympusini_metadata(inistr): """Return OlympusSIS metadata from INI string. No documentation is available. """ def keyindex(key): # split key into name and index index = 0 i = len(key.rstrip('0123456789')) if i < len(key): index = int(key[i:]) - 1 ...
[ "def", "olympusini_metadata", "(", "inistr", ")", ":", "def", "keyindex", "(", "key", ")", ":", "# split key into name and index", "index", "=", "0", "i", "=", "len", "(", "key", ".", "rstrip", "(", "'0123456789'", ")", ")", "if", "i", "<", "len", "(", ...
Return OlympusSIS metadata from INI string. No documentation is available.
[ "Return", "OlympusSIS", "metadata", "from", "INI", "string", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9234-L9334
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
tile_decode
def tile_decode(tile, tileindex, tileshape, tiledshape, lsb2msb, decompress, unpack, unpredict, out): """Decode tile segment bytes into 5D output array.""" _, imagedepth, imagelength, imagewidth, _ = out.shape tileddepth, tiledlength, tiledwidth = tiledshape tiledepth, tilelength, tilewi...
python
def tile_decode(tile, tileindex, tileshape, tiledshape, lsb2msb, decompress, unpack, unpredict, out): """Decode tile segment bytes into 5D output array.""" _, imagedepth, imagelength, imagewidth, _ = out.shape tileddepth, tiledlength, tiledwidth = tiledshape tiledepth, tilelength, tilewi...
[ "def", "tile_decode", "(", "tile", ",", "tileindex", ",", "tileshape", ",", "tiledshape", ",", "lsb2msb", ",", "decompress", ",", "unpack", ",", "unpredict", ",", "out", ")", ":", "_", ",", "imagedepth", ",", "imagelength", ",", "imagewidth", ",", "_", "...
Decode tile segment bytes into 5D output array.
[ "Decode", "tile", "segment", "bytes", "into", "5D", "output", "array", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9337-L9381
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
unpack_rgb
def unpack_rgb(data, dtype=None, bitspersample=None, rescale=True): """Return array from byte string containing packed samples. Use to unpack RGB565 or RGB555 to RGB888 format. Parameters ---------- data : byte str The data to be decoded. Samples in each pixel are stored consecutively. ...
python
def unpack_rgb(data, dtype=None, bitspersample=None, rescale=True): """Return array from byte string containing packed samples. Use to unpack RGB565 or RGB555 to RGB888 format. Parameters ---------- data : byte str The data to be decoded. Samples in each pixel are stored consecutively. ...
[ "def", "unpack_rgb", "(", "data", ",", "dtype", "=", "None", ",", "bitspersample", "=", "None", ",", "rescale", "=", "True", ")", ":", "if", "bitspersample", "is", "None", ":", "bitspersample", "=", "(", "5", ",", "6", ",", "5", ")", "if", "dtype", ...
Return array from byte string containing packed samples. Use to unpack RGB565 or RGB555 to RGB888 format. Parameters ---------- data : byte str The data to be decoded. Samples in each pixel are stored consecutively. Pixels are aligned to 8, 16, or 32 bit boundaries. dtype : numpy.d...
[ "Return", "array", "from", "byte", "string", "containing", "packed", "samples", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9384-L9438
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
delta_encode
def delta_encode(data, axis=-1, out=None): """Encode Delta.""" if isinstance(data, (bytes, bytearray)): data = numpy.frombuffer(data, dtype='u1') diff = numpy.diff(data, axis=0) return numpy.insert(diff, 0, data[0]).tobytes() dtype = data.dtype if dtype.kind == 'f': data...
python
def delta_encode(data, axis=-1, out=None): """Encode Delta.""" if isinstance(data, (bytes, bytearray)): data = numpy.frombuffer(data, dtype='u1') diff = numpy.diff(data, axis=0) return numpy.insert(diff, 0, data[0]).tobytes() dtype = data.dtype if dtype.kind == 'f': data...
[ "def", "delta_encode", "(", "data", ",", "axis", "=", "-", "1", ",", "out", "=", "None", ")", ":", "if", "isinstance", "(", "data", ",", "(", "bytes", ",", "bytearray", ")", ")", ":", "data", "=", "numpy", ".", "frombuffer", "(", "data", ",", "dt...
Encode Delta.
[ "Encode", "Delta", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9441-L9459
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
delta_decode
def delta_decode(data, axis=-1, out=None): """Decode Delta.""" if out is not None and not out.flags.writeable: out = None if isinstance(data, (bytes, bytearray)): data = numpy.frombuffer(data, dtype='u1') return numpy.cumsum(data, axis=0, dtype='u1', out=out).tobytes() if data.dt...
python
def delta_decode(data, axis=-1, out=None): """Decode Delta.""" if out is not None and not out.flags.writeable: out = None if isinstance(data, (bytes, bytearray)): data = numpy.frombuffer(data, dtype='u1') return numpy.cumsum(data, axis=0, dtype='u1', out=out).tobytes() if data.dt...
[ "def", "delta_decode", "(", "data", ",", "axis", "=", "-", "1", ",", "out", "=", "None", ")", ":", "if", "out", "is", "not", "None", "and", "not", "out", ".", "flags", ".", "writeable", ":", "out", "=", "None", "if", "isinstance", "(", "data", ",...
Decode Delta.
[ "Decode", "Delta", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9462-L9473
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
bitorder_decode
def bitorder_decode(data, out=None, _bitorder=[]): """Reverse bits in each byte of byte string or numpy array. Decode data where pixels with lower column values are stored in the lower-order bits of the bytes (TIFF FillOrder is LSB2MSB). Parameters ---------- data : byte string or ndarray ...
python
def bitorder_decode(data, out=None, _bitorder=[]): """Reverse bits in each byte of byte string or numpy array. Decode data where pixels with lower column values are stored in the lower-order bits of the bytes (TIFF FillOrder is LSB2MSB). Parameters ---------- data : byte string or ndarray ...
[ "def", "bitorder_decode", "(", "data", ",", "out", "=", "None", ",", "_bitorder", "=", "[", "]", ")", ":", "if", "not", "_bitorder", ":", "_bitorder", ".", "append", "(", "b'\\x00\\x80@\\xc0 \\xa0`\\xe0\\x10\\x90P\\xd00\\xb0p\\xf0\\x08\\x88H\\xc8('", "b'\\xa8h\\xe8\\x...
Reverse bits in each byte of byte string or numpy array. Decode data where pixels with lower column values are stored in the lower-order bits of the bytes (TIFF FillOrder is LSB2MSB). Parameters ---------- data : byte string or ndarray The data to be bit reversed. If byte string, a new bit...
[ "Reverse", "bits", "in", "each", "byte", "of", "byte", "string", "or", "numpy", "array", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9476-L9522
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
packints_decode
def packints_decode(data, dtype, numbits, runlen=0, out=None): """Decompress byte string to array of integers. This implementation only handles itemsizes 1, 8, 16, 32, and 64 bits. Install the imagecodecs package for decoding other integer sizes. Parameters ---------- data : byte str D...
python
def packints_decode(data, dtype, numbits, runlen=0, out=None): """Decompress byte string to array of integers. This implementation only handles itemsizes 1, 8, 16, 32, and 64 bits. Install the imagecodecs package for decoding other integer sizes. Parameters ---------- data : byte str D...
[ "def", "packints_decode", "(", "data", ",", "dtype", ",", "numbits", ",", "runlen", "=", "0", ",", "out", "=", "None", ")", ":", "if", "numbits", "==", "1", ":", "# bitarray", "data", "=", "numpy", ".", "frombuffer", "(", "data", ",", "'|B'", ")", ...
Decompress byte string to array of integers. This implementation only handles itemsizes 1, 8, 16, 32, and 64 bits. Install the imagecodecs package for decoding other integer sizes. Parameters ---------- data : byte str Data to decompress. dtype : numpy.dtype or str A numpy bool...
[ "Decompress", "byte", "string", "to", "array", "of", "integers", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9525-L9558
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
apply_colormap
def apply_colormap(image, colormap, contig=True): """Return palette-colored image. The image values are used to index the colormap on axis 1. The returned image is of shape image.shape+colormap.shape[0] and dtype colormap.dtype. Parameters ---------- image : numpy.ndarray Indexes into ...
python
def apply_colormap(image, colormap, contig=True): """Return palette-colored image. The image values are used to index the colormap on axis 1. The returned image is of shape image.shape+colormap.shape[0] and dtype colormap.dtype. Parameters ---------- image : numpy.ndarray Indexes into ...
[ "def", "apply_colormap", "(", "image", ",", "colormap", ",", "contig", "=", "True", ")", ":", "image", "=", "numpy", ".", "take", "(", "colormap", ",", "image", ",", "axis", "=", "1", ")", "image", "=", "numpy", ".", "rollaxis", "(", "image", ",", ...
Return palette-colored image. The image values are used to index the colormap on axis 1. The returned image is of shape image.shape+colormap.shape[0] and dtype colormap.dtype. Parameters ---------- image : numpy.ndarray Indexes into the colormap. colormap : numpy.ndarray RGB lo...
[ "Return", "palette", "-", "colored", "image", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9574-L9601
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
reorient
def reorient(image, orientation): """Return reoriented view of image array. Parameters ---------- image : numpy.ndarray Non-squeezed output of asarray() functions. Axes -3 and -2 must be image length and width respectively. orientation : int or str One of TIFF.ORIENTATION na...
python
def reorient(image, orientation): """Return reoriented view of image array. Parameters ---------- image : numpy.ndarray Non-squeezed output of asarray() functions. Axes -3 and -2 must be image length and width respectively. orientation : int or str One of TIFF.ORIENTATION na...
[ "def", "reorient", "(", "image", ",", "orientation", ")", ":", "orient", "=", "TIFF", ".", "ORIENTATION", "orientation", "=", "enumarg", "(", "orient", ",", "orientation", ")", "if", "orientation", "==", "orient", ".", "TOPLEFT", ":", "return", "image", "i...
Return reoriented view of image array. Parameters ---------- image : numpy.ndarray Non-squeezed output of asarray() functions. Axes -3 and -2 must be image length and width respectively. orientation : int or str One of TIFF.ORIENTATION names or values.
[ "Return", "reoriented", "view", "of", "image", "array", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9604-L9635
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
repeat_nd
def repeat_nd(a, repeats): """Return read-only view into input array with elements repeated. Zoom nD image by integer factors using nearest neighbor interpolation (box filter). Parameters ---------- a : array_like Input array. repeats : sequence of int The number of repetit...
python
def repeat_nd(a, repeats): """Return read-only view into input array with elements repeated. Zoom nD image by integer factors using nearest neighbor interpolation (box filter). Parameters ---------- a : array_like Input array. repeats : sequence of int The number of repetit...
[ "def", "repeat_nd", "(", "a", ",", "repeats", ")", ":", "a", "=", "numpy", ".", "asarray", "(", "a", ")", "reshape", "=", "[", "]", "shape", "=", "[", "]", "strides", "=", "[", "]", "for", "i", ",", "j", ",", "k", "in", "zip", "(", "a", "."...
Return read-only view into input array with elements repeated. Zoom nD image by integer factors using nearest neighbor interpolation (box filter). Parameters ---------- a : array_like Input array. repeats : sequence of int The number of repetitions to apply along each dimension...
[ "Return", "read", "-", "only", "view", "into", "input", "array", "with", "elements", "repeated", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9638-L9669
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
reshape_nd
def reshape_nd(data_or_shape, ndim): """Return image array or shape with at least ndim dimensions. Prepend 1s to image shape as necessary. >>> reshape_nd(numpy.empty(0), 1).shape (0,) >>> reshape_nd(numpy.empty(1), 2).shape (1, 1) >>> reshape_nd(numpy.empty((2, 3)), 3).shape (1, 2, 3) ...
python
def reshape_nd(data_or_shape, ndim): """Return image array or shape with at least ndim dimensions. Prepend 1s to image shape as necessary. >>> reshape_nd(numpy.empty(0), 1).shape (0,) >>> reshape_nd(numpy.empty(1), 2).shape (1, 1) >>> reshape_nd(numpy.empty((2, 3)), 3).shape (1, 2, 3) ...
[ "def", "reshape_nd", "(", "data_or_shape", ",", "ndim", ")", ":", "is_shape", "=", "isinstance", "(", "data_or_shape", ",", "tuple", ")", "shape", "=", "data_or_shape", "if", "is_shape", "else", "data_or_shape", ".", "shape", "if", "len", "(", "shape", ")", ...
Return image array or shape with at least ndim dimensions. Prepend 1s to image shape as necessary. >>> reshape_nd(numpy.empty(0), 1).shape (0,) >>> reshape_nd(numpy.empty(1), 2).shape (1, 1) >>> reshape_nd(numpy.empty((2, 3)), 3).shape (1, 2, 3) >>> reshape_nd(numpy.empty((3, 4, 5)), 3...
[ "Return", "image", "array", "or", "shape", "with", "at", "least", "ndim", "dimensions", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9672-L9694
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
squeeze_axes
def squeeze_axes(shape, axes, skip=None): """Return shape and axes with single-dimensional entries removed. Remove unused dimensions unless their axes are listed in 'skip'. >>> squeeze_axes((5, 1, 2, 1, 1), 'TZYXC') ((5, 2, 1), 'TYX') """ if len(shape) != len(axes): raise ValueError('...
python
def squeeze_axes(shape, axes, skip=None): """Return shape and axes with single-dimensional entries removed. Remove unused dimensions unless their axes are listed in 'skip'. >>> squeeze_axes((5, 1, 2, 1, 1), 'TZYXC') ((5, 2, 1), 'TYX') """ if len(shape) != len(axes): raise ValueError('...
[ "def", "squeeze_axes", "(", "shape", ",", "axes", ",", "skip", "=", "None", ")", ":", "if", "len", "(", "shape", ")", "!=", "len", "(", "axes", ")", ":", "raise", "ValueError", "(", "'dimensions of axes and shape do not match'", ")", "if", "skip", "is", ...
Return shape and axes with single-dimensional entries removed. Remove unused dimensions unless their axes are listed in 'skip'. >>> squeeze_axes((5, 1, 2, 1, 1), 'TZYXC') ((5, 2, 1), 'TYX')
[ "Return", "shape", "and", "axes", "with", "single", "-", "dimensional", "entries", "removed", "." ]
train
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9697-L9712