Tag Info

8

The Neurotica package by Noah Benson has support for importing NifTI files. It registers the "NIFTI" import format, to make importing as convenient as Import["somefile.nii", "NIFTI"]. However, by default this returns an MRImage3D object, which is specific to the Neurotica package and doesn't support arbitrary dimensional data. If the data is high ...

3

As others have explained, the basic web page that gets imported doesn't contain any images. This is because many (most) web pages are not served as static entities, but have dynamic behavior due to javascript execution. So Import is not going to be terribly useful here. However, when you use my WebUnit package, this is easy: WebUnit talks directly to a ...

4

The link to the picture itself is stored in a data-src element of each hyperlink. You will have to use string patterns to extract them. For instance, you could use the following as a starting point: url = "http://www.worldwideinterweb.com/item/3678-50-horrible-photos-by-horrible-professional-photographers.html"; StringCases[ Import[url, "Source"], ...

1

Looking at the result of Union@Import[url, "ImageLinks"] appears to give an answer: {"http://www.worldwideinterweb.com/plugins/system/lazyloadforjoomla/blank.gif"} It is very likely the images are loaded on demand by the scripts on the page. So, Import[..., "ImageLinks"] can't be used to spider through them.

6

data = Import["/Users/roberthanlon/Downloads/test.xlsx"][[1]]; Dimensions[data] {6039, 2} Since the data consists of pairs of values, the distribution given by SmoothKernelDistribution[data] is for a bivariate distribution. K = SmoothKernelDistribution[data]; {xmin, xmax} = MinMax[data[[All, 1]]]; {ymin, ymax} = MinMax[data[[All, 2]]]; ...

3

You can even read the following How to | Import a Spreadsheet data = Import["/Users/xxx/Desktop/test.xlsx", {"Data", 1, All, 1}]; K = SmoothKernelDistribution[data]; Table[Plot[f[K, x], {x, -1000, 4000}, PlotLabel -> f], {f, {PDF, CDF}}] How to | Import a Spreadsheet The spreadsheet is included in the Wolfram Language documentation folder ...

4

How about SetDirectory["D:Experiments\\"]; names = FileNames["*.txt"]; Do[ data = Import[name, "Table"]; range = Select[data, 400 < #[[1]] < 550 &]; smooth = Interpolation[range, InterpolationOrder -> 3]; ex = Table[{x,smooth[x]}, {x, 400, 550, 0.050}]; Export[FileBaseName[name]<>"-out.txt", ex, "Table"];, {name, ...

3

Exporting a 3D graphic that contains more than one Hexahedron object doesn't seem to work. The problem seems to stem from the fact that Export calls DiscretizeGraphics on the Graphics3D object, and DiscretizeGraphics can't handle the input. Both Export and ExportString work (i.e. fail) in the same way: ExportString[Graphics3D[{Hexahedron[], Hexahedron[]}], ...

3

an example of a grid of plots: GraphicsGrid[ Partition[Table[ Plot[Sin[i x] , {x, 0, 2 Pi}], {i, 7}], 3, 3 , {1, 1}, Null]] then for your case it will be something like: GraphicsGrid[ Partition[Table[ p=ReadList[]; ... ListPlot[...], {i, Length[datasource]}], 3, 3 , {1, 1}, Null]]

2

Just to get an answer on this one, since it finally fixed someone's problem. Sometimes things get corrupted in MMA's initialization files which leads to strange, usually low-level complaints, e.g. can't import MP3. The fix is easy, so it's always a good first step when you see that red pop-up. (And confirmed that the user isn't to blame...) To keep this ...

3

It appears that HDF.exe crashes. This should not happen and I think this is a bug. On OS X I can reproduce the crash with M9.0, but not with M10.0 or later. On Linux I can reproduce the crash with M10.2 too. A possible workaround is to convert the file from HDF4 to HDF5 format. You could use the h4toh5 tool for this, which I installed using MacPorts. ...

5

The "Details and Options" section of the documentation of FileNames states that "The list of files returned by FileNames is sorted in the order generated by the function Sort." so the list will be in lexicographic order, and I suspect that your files will not be imported as you showed. files = {"zug1.phz", "zug2.phz", "zug3.phz", "zug4.phz", "zug5.phz", ...

1

Here is my quick answer. Import the data from the files: files = FileNames["/sample_data/1_5ormore_methy_00*"]; data = Import[#, "Table"] & /@ files; Define a function to compute your values: f[s1_, s2_, vals_] := Times @@ (Beta[First@# + s1, Last@# + s2] & /@vals)/Beta[s1, s2]^Length@vals Apply the function to the data for each of the ...

1

Of course this is possible. But I suggest that you break the problem down in smaller steps. Let's start with the problem of reading many files. If you have them in one directory, it can be as simple as files = FileNames["a*"]; data = Import[#,"Table"] &/@ files; This fills the list data with sub-lists, that contain the data n each file. Now you ...

6

URLDecode and URLEncode were introduced in Mathematica 10.0: url = "https%3A%2F%2Fwww.google.co.uk%2Fimages%2Fsrpr%2Flogo4w.png"; URLDecode[url] (*"https://www.google.co.uk/images/srpr/logo4w.png"*) The symbol definition can be accessed as follows, which is scarily close to @Guesswhoitis's code above. URLDecode[url]; Unprotect[URLDecode]; ...

1

The use of ExportString and/or ImportString, which in fact just use Export and Import on temporary files, seems to trigger dynamic updates. Front-End options get changed and perhaps some variables, and it must be that some of these are tracked. It's difficult to know whether they ought to be or not. In any case, a side effect is the continual updating of ...

4

As @gnosygnu mentioned in the comments of his answer, the problem is with the "Content-Type" header. So as a temporary fix before XOWA is updated, this works: ImportString[URLFetch["http://localhost:8080/en.wikipedia.org/wiki/Test", "Content","Headers"->{"Content-Type"->""}],"XMLObject"]

5

Possibly you want the Import format "HeldExpressions": Import["test", "HeldExpressions"] {HoldComplete[A = {1, 2, 3, 4, 5}], HoldComplete[B = {1, 4, 9, 16, 25}], HoldComplete[Attributes[C] = {NHoldAll, Protected}]} The last expression may not be as you expect until you remember that C is a reserved System Symbol. Sorry, I overlooked the fact ...

5

Not all parts of your file are recognized as numeric data during the Import. u = Import["file.dat"] Head /@ Flatten[u] $\$ {String, Integer, Integer, String} You can convert it for example with SetAttributes[stringToNumber, Listable]; stringToNumber[s_String] := ToExpression[StringReplace[s, {"e" -> " 10^", "i" -> " I"}]]; stringToNumber[s_] := ...

6

One possibility: try this (you can use Import on your file instead): lines = ImportString[ "1+1e-18i 24 42 23.43e-23i", "Lines"] Then: result = Map[StringSplit, lines] And: Map[Interpreter["ComplexNumber"], result, {2}] This gives: {{1. + 1.*^-18 I, 24}, {42, 0. + 2.343*^-22 I}}

Top 50 recent answers are included